This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Minimal examples of polyglot Rmd" | |
author: "Henry Miller" | |
date: "3/2/2022" | |
output: html_document | |
--- | |
## Minimal example of polyglot python + R in RMarkdown | |
First, we load the `iris` dataset using seaborn in **python**: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(msigdbr) | |
library(dplyr) | |
msigdbr(category = "C8") %>% | |
dplyr::select(gs_name, gene_symbol) %>% | |
distinct(gs_name, gene_symbol) %>% | |
mutate(val = 1) %>% | |
pivot_wider( | |
id_cols = gs_name, names_from = gene_symbol, | |
values_from = val, | |
values_fill = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(magrittr) | |
# Venn diagram plot in tidy pipe | |
plt <- list( | |
"A" = 1:100, | |
"B" = 96:140 | |
) %>% | |
VennDiagram::venn.diagram(filename = NULL) %>% | |
grid::grid.draw(.) %>% | |
ggplotify::grid2grob() %>% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create links in datatabels for gene info modal | |
createGeneInfoLink <- function(val) { | |
sprintf(paste0('<a href="https://www.genecards.org/cgi-bin/carddisp.pl?gene=', val ,'" target="_blank" class="tooltip-test" onClick="gene_click(this.id)" title="', val, '">', val, '</a>')) | |
} | |
# Create links in datatables for GSEA info from MSIGDB | |
createGSEAInfoLink <- function(val, valTitle) { | |
sprintf(paste0('<a href="http://software.broadinstitute.org/gsea/msigdb/cards/', val,'" id="', val ,'" target="_blank" class="tooltip-test" onClick="gsea_click(this.id)" title="', val, '">', valTitle, '</a>')) | |
} | |
# Create links in datatables for GEO accessions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
encExp2Peaks <- function(acc, getIDR=FALSE) { | |
resp <- httr::GET(url = paste0("https://www.encodeproject.org/search/?type=File&dataset=/experiments/", | |
acc,"/&file_type=bed+narrowPeak&format=json&frame=object&limit=all"), httr::accept_json()) %>% | |
httr::content(as="parsed") | |
res <- lapply(seq(resp$`@graph`), function(i) { | |
entry <- resp$`@graph`[[i]] | |
tibble( | |
accfile = entry$accession, | |
sup = ! is.null(entry$superseded_by %>% unlist()), | |
type = entry$file_type, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
bamToBed -i $BAM_ORIG -bed12 -cigar | shuffleBed -i - -g $CHROM_SIZES | bedToBam -bed12 -g $CHROM_SIZES | samtools sort > $BAM_SHUFFLED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script for wrangling test files to correct naming conventions | |
library(tidyverse) | |
library(parallel) | |
S3_BAM_URI <- "s3://rseq-testing/bam-files/" | |
bamsAvail <- system(paste0("aws s3 ls ", S3_BAM_URI), intern = TRUE) | |
oldnew <- tibble( | |
oldfls = gsub(bamsAvail, pattern = ".+ ([ES]{1}RX[0-9]+_.+\\.[hgmm]{2}[0-9]+\\.bam)", replacement = "\\1"), | |
newfls = gsub(bamsAvail, pattern = ".+ ([ES]{1}RX[0-9]+)_.+\\.([hgmm]{2}[0-9]+\\.bam)", replacement = "\\1_\\2") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get_public_run_info <- function(accessions) { | |
suppressWarnings(suppressPackageStartupMessages(require(XML))) | |
httr::set_config(httr::config(http_version = 2)) | |
# set the HTTP version to 1.1 (none, 1.0, 1.1, 2) | |
#### Bug testing ## | |
#accessions <- c("SRX2481503", "SRX2481504", "GSE134101", "SRP150774", "GSE127329", "SRS1466492") | |
#accessions <- c("SRX2918366", "SRX2918367", "GSM3936516", "SRX5129664") |
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 27 columns, instead of 22 in line 2.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UCSC_orgID description nibPath organism defaultPos active orderKey genome scientificName htmlPath hgNearOk hgPbOk sourceName taxId genes_available year eff_genome_size_36bp eff_genome_size_50bp eff_genome_size_75bp eff_genome_size_100bp eff_genome_size_125bp eff_genome_size_150bp eff_genome_size_200bp eff_genome_size_250bp eff_genome_size_300bp genome_length homer_anno_available | |
ailMel1 Dec. 2009 (BGI-Shenzhen 1.0/ailMel1) /gbdb/ailMel1 Panda GL192818.1:558576-566855 1 16070 Panda Ailuropoda melanoleuca /gbdb/ailMel1/html/description.html 0 0 BGI-Shenzhen AilMel 1.0 Dec. 2009 9646 TRUE 2009 2131884815 2195257147 2167233843 2206501040 2213941269 2196290908 2233702932 2212959190 2168863899 2299509015 FALSE | |
allMis1 Aug. 2012 (allMis0.2/allMis1) /gbdb/allMis1 American alligator JH731472:504271-884586 1 1425 American alligator Alligator mississippiensis /gbdb/allMis1/html/description.html 0 0 International Crocodilian Genomes Working Group 8496 TRUE 2012 2050346072 2080458921 2117005123 2101224009 2132575305 21480 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
env: | |
RENV_PATHS_ROOT: ~/.local/share/renv | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main |
NewerOlder