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(recount) | |
library(edgeR) | |
#/ Get the counts from GTEx via recount as a SummarizedExperiment | |
#/ => 1.3GB file | |
options(timeout=600) | |
download_study("SRP012682", type = "rse-gene") | |
load(file.path("SRP012682", "rse_gene.Rdata")) | |
#/ remove whitespaces in tissue names: |
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
$ head renv.lock -n 40 | |
{ | |
"R": { | |
"Version": "4.0.3", | |
"Repositories": [ | |
{ | |
"Name": "CRAN", | |
"URL": "https://cran.rstudio.com" | |
} | |
] |
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
#!/usr/bin/env nextflow | |
nextflow.enable.dsl=2 | |
// Dummy example: Decompress a BAM in processA => stdout => read in processB as stdin and compress back to BAM. | |
process processA { | |
input: | |
path(bam) |
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
$ make | |
mkdir -p objs | |
g++ -std=c++11 -Wall -O3 -fopenmp -march=native -c src/chromap.cc -o objs/chromap.o -lm -lz | |
src/chromap.cc:1096:0: warning: ignoring #pragma omp taskloop [-Wunknown-pragmas] | |
#pragma omp taskloop grainsize(grain_size) //num_tasks(num_threads_* 50) | |
^ | |
src/chromap.cc:2001:0: warning: ignoring #pragma omp taskloop [-Wunknown-pragmas] | |
#pragma omp taskloop num_tasks(num_threads_* num_threads_) | |
^ | |
src/chromap.cc: In instantiation of 'void chromap::Chromap<MappingRecord>::MapSingleEndReads() [with MappingRecord = chromap::PAFMapping]': |
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(DESeq2) | |
#/ from https://raw.githubusercontent.com/shangguandong1996/picture_link/main/WFX_count_Rmatrix.txt | |
data <- read.delim("WFX_count_Rmatrix.txt", row.names = "Geneid") | |
get_res <- function(dds){ | |
dds <- DESeq(dds) | |
res <- results(dds, name=resultsNames(dds)[2]) | |
lfcShrink(dds, coef=resultsNames(dds)[2], res=res, type="ashr") | |
} |
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(ggplot2) | |
library(reshape2) | |
library(egg) | |
# thanks to https://stackoverflow.com/questions/1330989/rotating-and-spacing-axis-labels-in-ggplot2/60650595#60650595 | |
dat<-reshape2::melt(data.frame(groupA=rnorm(20), | |
groupB=rnorm(20), | |
groupC=rnorm(20))) |
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
# install.packages("data.table", "dplyr") | |
library(data.table) | |
library(dplyr) | |
parseProperly <- function(x){ | |
x <- x[,-c(ncol(x)-1,ncol(x))] | |
x | |
} |
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
cb <- c("#E69F00", "#0072B2", "#009E73", | |
"#CC79A7", "#56B4E9", "#D55E00", | |
"#661100", "#F0E442", "#332288", | |
"gray40", "black") | |
library(ggplot2) | |
ggplot(data.frame(x=c(rep(c(1,2,3), each=3), 4,4), y=1:length(l), color=LETTERS[1:length(l)]), | |
aes(x=x, y=y, color=color)) + | |
geom_point(size=10, show.legend=FALSE) + |
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
#' Take output of UCell::ScoreSignatures_UCell() and return a vector of labels with highest score. | |
#' If the highest score per row is unique (only one value is the highest value) return that label. | |
#' If all scores are zero return "NA". | |
#' If more than one value is the highest value return "ambiguous". | |
#' library(UCell) | |
#' data(sample.matrix) | |
#' gene.sets <- list(Tcell_signature = c("CD2","CD3E","CD3D"), | |
#' Myeloid_signature = c("SPI1","FCER1G","CSF1R")) | |
#' scores <- ScoreSignatures_UCell(sample.matrix, features=gene.sets) | |
#' convertUCell(scores) |
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
# Given a matrix-like object with genes being rows and samples being columns, | |
# and a group information for the columns, calculate the percentage of columns per group | |
# that have counts > threshold per gene. Efficiently done via base R, compatible with dgCMatrix. | |
# data <- data.frame(A=c(1,1,0,0), B=c(1,0,0,0), C=c(1,0,0,0)) | |
# group <- as.character(c(1,1,2)) | |
get_pexpr <- function(data, group, threshold=0, digits=2){ | |
if(ncol(data)!=length(group)) stop("ncol(data) != length(group)") | |
if(!is.numeric(threshold) | threshold < 0) stop("threshold must be numeric and > 0") | |