All Projects → jumphone → BEER

jumphone / BEER

Licence: MIT license
BEER: Batch EffEct Remover for single-cell data

Programming Languages

r
7636 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to BEER

scarf
Toolkit for highly memory efficient analysis of single-cell RNA-Seq, scATAC-Seq and CITE-Seq data. Analyze atlas scale datasets with millions of cells on laptop.
Stars: ✭ 54 (+184.21%)
Mutual labels:  scrna-seq, umap, scatac-seq
babel
Deep learning model for single-cell inference of multi-omic profiles from a single input modality.
Stars: ✭ 20 (+5.26%)
Mutual labels:  scrna-seq, scatac-seq
SPLiT-Seq demultiplexing
An unofficial demultiplexing strategy for SPLiT-seq RNA-Seq data
Stars: ✭ 20 (+5.26%)
Mutual labels:  scrna-seq, single-cell-analysis
SHARP
SHARP: Single-cell RNA-seq Hyper-fast and Accurate processing via ensemble Random Projection
Stars: ✭ 14 (-26.32%)
Mutual labels:  scrna-seq, single-cell-analysis
Nebulosa
R package to visualize gene expression data based on weighted kernel density estimation
Stars: ✭ 50 (+163.16%)
Mutual labels:  single-cell-analysis
Sierra
Discover differential transcript usage from polyA-captured single cell RNA-seq data
Stars: ✭ 37 (+94.74%)
Mutual labels:  scrna-seq
cardelino
Clone identification from single-cell data
Stars: ✭ 49 (+157.89%)
Mutual labels:  scrna-seq
dropEst
Pipeline for initial analysis of droplet-based single-cell RNA-seq data
Stars: ✭ 71 (+273.68%)
Mutual labels:  scrna-seq
symphony
Efficient and precise single-cell reference atlas mapping with Symphony
Stars: ✭ 69 (+263.16%)
Mutual labels:  scrna-seq
scGEAToolbox
scGEAToolbox: Matlab toolbox for single-cell gene expression analyses
Stars: ✭ 15 (-21.05%)
Mutual labels:  scrna-seq
snATAC
<<------ Use SnapATAC!!
Stars: ✭ 23 (+21.05%)
Mutual labels:  single-cell-analysis
ALRA
Imputation method for scRNA-seq based on low-rank approximation
Stars: ✭ 48 (+152.63%)
Mutual labels:  scrna-seq
Tangram
Spatial alignment of single cell transcriptomic data.
Stars: ✭ 149 (+684.21%)
Mutual labels:  scrna-seq
dynmethods
A collection of 50+ trajectory inference methods within a common interface 📥📤
Stars: ✭ 94 (+394.74%)
Mutual labels:  single-cell-analysis
DRComparison
Comparison of dimensionality reduction methods
Stars: ✭ 29 (+52.63%)
Mutual labels:  single-cell-analysis
cerebra
A tool for fast and accurate summarizing of variant calling format (VCF) files
Stars: ✭ 55 (+189.47%)
Mutual labels:  scrna-seq
clustergrammer2-notebooks
Examples using Clustergrammer2 to explore high-dimensional datasets.
Stars: ✭ 35 (+84.21%)
Mutual labels:  scrna-seq
northstar
Single cell type annotation guided by cell atlases, with freedom to be queer
Stars: ✭ 23 (+21.05%)
Mutual labels:  scrna-seq
ParametricUMAP paper
Parametric UMAP embeddings for representation and semisupervised learning. From the paper "Parametric UMAP: learning embeddings with deep neural networks for representation and semi-supervised learning" (Sainburg, McInnes, Gentner, 2020).
Stars: ✭ 132 (+594.74%)
Mutual labels:  umap
dyngen
Simulating single-cell data using gene regulatory networks 📠
Stars: ✭ 59 (+210.53%)
Mutual labels:  single-cell-analysis

BEER: Batch EffEct Remover for single-cell data

Environment: R

BEER's latest version: https://github.com/jumphone/BEER/releases

News:

  • Mar. 2021 ( V0.1.9 ): First version for Seurat 4.0.0

  • Feb. 2021 ( V0.1.8 ): Last version for Seurat 3.0.0

  • Nov. 2019 ( v0.1.7 ): In ".simple_combine(D1, D2, FILL=TRUE)", "FILL" can help users to keep genes that are expressed in only one condition (fill the matrix with “0”). Default "FILL" is FALSE

  • July 2019 ( v0.1.6 ): BEER can automatically adjust "GNUM" when cell number is small in some batch

  • July 2019 ( v0.1.5 ): "ComBat" is used to replace "regression" of "ScaleData" (ComBat is much faster)

  • July 2019 ( v0.1.4 ): Users can provide genes which need to be removed.

  • July 2019 ( v0.1.3 ): Users can use VISA to extract peaks of scATAC-seq.

  • ...

Content:





Workflow:

Latest version

Please see V. Batch-effect Removal Enhancement for details of "Enhancement".



Requirement:

#R >=3.5
install.packages('Seurat') # ==4.0.0 

# Install ComBat:
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("sva")
BiocManager::install("limma")

# Users can use "BEER" by directly importing "BEER.R" on the github webpage:

source('https://raw.githubusercontent.com/jumphone/BEER/master/BEER.R')

# Or, download and import it:

source('BEER.R')

For batch-effect removal enhancement, please install BBKNN: https://github.com/Teichlab/bbknn



Vignettes:


Set Python

library(reticulate)
use_python("/home/toolkit/local/bin/python3",required=T)
py_config()

I. Combine Two Batches

Download demo data: https://github.com/jumphone/BEER/raw/master/DATA/demodata.zip

Please do basic quality control before using BEER (e.g. remove low-quality cells & genes).

For QC, please see: https://satijalab.org/seurat/v3.0/pbmc3k_tutorial.html

Step1. Load Data

library(Seurat)

source('https://raw.githubusercontent.com/jumphone/BEER/master/BEER.R')
#source('BEER.R')

#Read 10X data: pbmc.data <- Read10X(data.dir = "../data/pbmc3k/filtered_gene_bc_matrices/hg19/")

#Load Demo Data (subset of GSE70630: MGH53 & MGH54)
#Download: https://github.com/jumphone/BEER/raw/master/DATA/demodata.zip

D1 <- read.table(unz("demodata.zip","DATA1_MAT.txt"), sep='\t', row.names=1, header=T)
D2 <- read.table(unz("demodata.zip","DATA2_MAT.txt"), sep='\t', row.names=1, header=T)

# "D1" & "D2" are UMI matrix (or FPKM, RPKM, TPM, PKM ...; Should not be gene-centric scaled data)
# Rownames of "D1" & "D2" are gene names
# Colnames of "D1" & "D2" are cell names 

# There shouldn't be duplicated colnames in "D1" & "D2":
colnames(D1)=paste0('D1_', colnames(D1))
colnames(D2)=paste0('D2_', colnames(D2))

DATA=.simple_combine(D1,D2)$combine

# Users can use "DATA=.simple_combine(D1,D2, FILL=TRUE)$combine" to keep genes that are expressed in only one condition.

BATCH=rep('D2',ncol(DATA))
BATCH[c(1:ncol(D1))]='D1'

# Simple Quality Control (QC): check the number of sequenced genes
# PosN=apply(DATA,2,.getPos)
# USED=which(PosN>500 & PosN<4000) 
# DATA=DATA[,USED]; BATCH=BATCH[USED] 

Step2. Detect Batch Effect

mybeer=BEER(DATA, BATCH, GNUM=30, PCNUM=50, ROUND=1, GN=2000, SEED=1, COMBAT=TRUE, RMG=NULL)   

# DATA: Expression matrix. Rownames are genes. Colnames are cell names.
# BATCH: A character vector. Length is equal to the "ncol(DATA)".
# GNUM: the number of groups in each batch (default: 30)
# PCNUM: the number of computated PCA subspaces (default: 50)
# ROUND: batch-effect removal strength, positive integer (default: 1)
# GN: the number of variable genes in each batch (default: 2000)
# RMG: genes need to be removed (default: NULL)
# COMBAT: use ComBat to adjust expression value(default: TRUE)    

# Users can use "ReBEER" to adjust GNUM, PCNUM, ROUND, and RMG (it's faster than directly using BEER).
# mybeer <- ReBEER(mybeer, GNUM=30, PCNUM=50, ROUND=1, SEED=1, RMG=NULL) 

# Check selected PCs
PCUSE=mybeer$select
COL=rep('black',length(mybeer$cor))
COL[PCUSE]='red'
plot(mybeer$cor,mybeer$lcor,pch=16,col=COL,
    xlab='Rank Correlation',ylab='Linear Correlation',xlim=c(0,1),ylim=c(0,1))

Users can select PCA subspaces based on the distribution of "Rank Correlation" and "Linear Correlation".

# PCUSE=.selectUSE(mybeer, CUTR=0.7, CUTL=0.7, RR=0.5, RL=0.5)

Step3. Visualization

Keep batch effect:

pbmc_batch=CreateSeuratObject(counts = DATA, min.cells = 0, min.features = 0, project = "ALL") 
[email protected]$batch=BATCH
pbmc_batch=FindVariableFeatures(object = pbmc_batch, selection.method = "vst", nfeatures = 2000)   
VariableFeatures(object = pbmc_batch)
pbmc_batch <- NormalizeData(object = pbmc_batch, normalization.method = "LogNormalize", scale.factor = 10000)
pbmc_batch <- ScaleData(object = pbmc_batch, features = VariableFeatures(object = pbmc_batch))
pbmc_batch <- RunPCA(object = pbmc_batch, seed.use=123, npcs=50, features = VariableFeatures(object = pbmc_batch), ndims.print=1,nfeatures.print=1)
pbmc_batch <- RunUMAP(pbmc_batch, dims = 1:50, seed.use = 123,n.components=2)
DimPlot(pbmc_batch, reduction='umap', group.by='batch', pt.size=0.1) 

Remove batch effect:

pbmc <- mybeer$seurat
PCUSE <- mybeer$select
pbmc <- RunUMAP(object = pbmc, reduction='pca',dims = PCUSE, check_duplicates=FALSE)

DimPlot(pbmc, reduction='umap', group.by='batch', pt.size=0.1) 



II. Combine Multiple Batches

Download demo data: https://sourceforge.net/projects/beergithub/files/

Step1. Load Data

source('https://raw.githubusercontent.com/jumphone/BEER/master/BEER.R')

#Load Demo Data (Oligodendroglioma, GSE70630)
#Download: https://sourceforge.net/projects/beergithub/files/

D1=readRDS('MGH36.RDS')
D2=readRDS('MGH53.RDS')
D3=readRDS('MGH54.RDS')
D4=readRDS('MGH60.RDS')
D5=readRDS('MGH93.RDS')
D6=readRDS('MGH97.RDS')

BATCH=c(rep('D1',ncol(D1)),
        rep('D2',ncol(D2)),
        rep('D3',ncol(D3)),
        rep('D4',ncol(D4)),
        rep('D5',ncol(D5)),
        rep('D6',ncol(D6)) )
        
D12=.simple_combine(D1,D2)$combine
D34=.simple_combine(D3,D4)$combine
D56=.simple_combine(D5,D6)$combine
D1234=.simple_combine(D12,D34)$combine
D123456=.simple_combine(D1234,D56)$combine

DATA=D123456   

rm(D1);rm(D2);rm(D3);rm(D4);rm(D5);rm(D6)
rm(D12);rm(D34);rm(D56);rm(D1234);rm(D123456)

# Simple Quality Control (QC): check the number of sequenced genes
# PosN=apply(DATA,2,.getPos)
# USED=which(PosN>500 & PosN<4000) 
# DATA=DATA[,USED]; BATCH=BATCH[USED] 

Step2. Use BEER to Detect Batch Effect

mybeer=BEER(DATA, BATCH, GNUM=30, PCNUM=50, ROUND=1, GN=2000, SEED=1, COMBAT=TRUE )

# Check selected PCs
PCUSE=mybeer$select
COL=rep('black',length(mybeer$cor))
COL[PCUSE]='red'
plot(mybeer$cor,mybeer$lcor,pch=16,col=COL,
    xlab='Rank Correlation',ylab='Linear Correlation',xlim=c(0,1),ylim=c(0,1))

Step3. Visualization

Keep batch effect:

pbmc_batch=CreateSeuratObject(counts = DATA, min.cells = 0, min.features = 0, project = "ALL") 
[email protected]$batch=BATCH
pbmc_batch=FindVariableFeatures(object = pbmc_batch, selection.method = "vst", nfeatures = 2000)   
VariableFeatures(object = pbmc_batch)
pbmc_batch <- NormalizeData(object = pbmc_batch, normalization.method = "LogNormalize", scale.factor = 10000)
pbmc_batch <- ScaleData(object = pbmc_batch, features = VariableFeatures(object = pbmc_batch))
pbmc_batch <- RunPCA(object = pbmc_batch, seed.use=123, npcs=50, features = VariableFeatures(object = pbmc_batch), ndims.print=1,nfeatures.print=1)
pbmc_batch <- RunUMAP(pbmc_batch, dims = 1:50, seed.use = 123,n.components=2)
DimPlot(pbmc_batch, reduction='umap', group.by='batch', pt.size=0.1) 

Remove batch effect:

pbmc <- mybeer$seurat
PCUSE <- mybeer$select
pbmc <- RunUMAP(object = pbmc, reduction='pca',dims = PCUSE, check_duplicates=FALSE)

DimPlot(pbmc, reduction='umap', group.by='batch', pt.size=0.1)   



III. UMAP-based Clustering

VEC=pbmc@[email protected]

# Here, we use K-means to do the clustering
N=20
set.seed(123)
K=kmeans(VEC,centers=N)

CLUST=K$cluster
[email protected]$clust=as.character(CLUST)
DimPlot(pbmc, reduction='umap', group.by='clust', pt.size=0.5,label=TRUE)

# Or, manually select some cells

ppp=DimPlot(pbmc, reduction='umap', pt.size=0.5)
used.cells <- CellSelector(plot = ppp)

# Press "ESC"

markers <- FindMarkers(pbmc, ident.1=used.cells,only.pos=T)    
head(markers, n=20)


IV. Combine scATAC-seq & scRNA-seq

Please install "Signac": https://satijalab.org/signac/

Download DEMO data: https://sourceforge.net/projects/beer-file/files/ATAC/ & https://satijalab.org/signac/articles/pbmc_vignette.html

Step1. Load Data

source('https://raw.githubusercontent.com/jumphone/BEER/master/BEER.R')
#source('BEER.R')

library(Seurat)
library(Signac)
library(EnsDb.Hsapiens.v75)

counts <- Read10X_h5(filename = "./data/atac_v1_pbmc_10k_filtered_peak_bc_matrix.h5")

metadata <- read.csv(
  file = "./data/atac_v1_pbmc_10k_singlecell.csv",
  header = TRUE,
  row.names = 1
    )

chrom_assay <- CreateChromatinAssay(
    counts = counts,
    sep = c(":", "-"),
    genome = 'hg19',
    fragments = './data/atac_v1_pbmc_10k_fragments.tsv.gz',
    min.cells = 10,
    min.features = 200
   )

pbmc.atac <- CreateSeuratObject(
    counts = chrom_assay,
    assay = "peaks",
    meta.data = metadata
    )

annotations <- GetGRangesFromEnsDb(ensdb = EnsDb.Hsapiens.v75)
seqlevelsStyle(annotations) <- "UCSC"
genome(annotations) <- "hg19"
Annotation(pbmc.atac) <- annotations


gene.activities <- GeneActivity(pbmc.atac)
     
pbmc.rna <- readRDS("./data/pbmc_10k_v3.rds")

D1=as.matrix(gene.activities)
D2=as.matrix(pbmc.rna@assays$RNA@counts)
colnames(D1)=paste0('ATAC_', colnames(D1))
colnames(D2)=paste0('RNA_', colnames(D2))

D1=.check_rep(D1)
D2=.check_rep(D2)

DATA=.simple_combine(D1,D2)$combine
BATCH=rep('RNA',ncol(DATA))
BATCH[c(1:ncol(D1))]='ATAC'

Step2. Use BEER to Detect Batch Effect

mybeer <- BEER(DATA, BATCH, GNUM=30, PCNUM=50, ROUND=1, GN=5000, SEED=1, COMBAT=TRUE)
saveRDS(mybeer, file='mybeer')

# Users can use "ReBEER" to adjust parameters
mybeer <- ReBEER(mybeer, GNUM=100, PCNUM=100, ROUND=3, SEED=1)

PCUSE=mybeer$select
#PCUSE=.selectUSE(mybeer, CUTR=0.8, CUTL=0.8, RR=0.5, RL=0.5)

COL=rep('black',length(mybeer$cor))
COL[PCUSE]='red'
plot(mybeer$cor,mybeer$lcor,pch=16,col=COL,
    xlab='Rank Correlation',ylab='Linear Correlation',xlim=c(0,1),ylim=c(0,1))

Step3. Visualization

Keep batch effect:

pbmc_batch=CreateSeuratObject(counts = DATA, min.cells = 0, min.features = 0, project = "ALL") 
[email protected]$batch=BATCH
pbmc_batch=FindVariableFeatures(object = pbmc_batch, selection.method = "vst", nfeatures = 2000)   
VariableFeatures(object = pbmc_batch)
pbmc_batch <- NormalizeData(object = pbmc_batch, normalization.method = "LogNormalize", scale.factor = 10000)
pbmc_batch <- ScaleData(object = pbmc_batch, features = VariableFeatures(object = pbmc_batch))
pbmc_batch <- RunPCA(object = pbmc_batch, seed.use=123, npcs=50, features = VariableFeatures(object = pbmc_batch), ndims.print=1,nfeatures.print=1)
pbmc_batch <- RunUMAP(pbmc_batch, dims = 1:50, seed.use = 123,n.components=2)
DimPlot(pbmc_batch, reduction='umap', group.by='batch', pt.size=0.1)   

Remove batch effect:

pbmc <- mybeer$seurat  
PCUSE=mybeer$select
pbmc <- RunUMAP(object = pbmc, reduction='pca',dims = PCUSE, check_duplicates=FALSE)

DimPlot(pbmc, reduction='umap', group.by='batch', pt.size=0.1)    

[email protected]$celltype=rep(NA,length([email protected]$batch))
[email protected]$celltype[which([email protected]$batch=='RNA')][email protected]$celltype

DimPlot(pbmc, reduction='umap', group.by='celltype', pt.size=0.1,label=T)

saveRDS(mybeer, file='mybeer.final.RDS')

It's not good enough !

For further enhancement, please see V. Batch-effect Removal Enhancement.



V. Batch-effect Removal Enhancement

Please install BBKNN: https://github.com/Teichlab/bbknn

This DEMO follows IV. Combine scATAC-seq & scRNA-seq

source('https://raw.githubusercontent.com/jumphone/BEER/master/BEER.R')
#source('BEER.R')
mybeer=readRDS('mybeer.final.RDS')
pbmc.rna <- readRDS("./data/pbmc_10k_v3.rds")

Use ComBat & BBKNN without BEER:

pbmc <- mybeer$seurat
PCUSE=c(1:ncol(pbmc@[email protected]))
pbmc=BEER.combat(pbmc) #Adjust PCs using ComBat
umap=BEER.bbknn(pbmc, PCUSE, NB=3, NT=10)
pbmc@[email protected]=umap
DimPlot(pbmc, reduction='umap', group.by='batch', pt.size=0.1,label=F)

Use ComBat & BBKNN with BEER:

pbmc <- mybeer$seurat
PCUSE=mybeer$select   
pbmc=BEER.combat(pbmc) #Adjust PCs using ComBat
umap=BEER.bbknn(pbmc, PCUSE, NB=3, NT=10)
pbmc@[email protected]=umap
DimPlot(pbmc, reduction='umap', group.by='batch', pt.size=0.1,label=F)
 
saveRDS(pbmc, file='seurat.enh.RDS')

[email protected]$celltype=rep(NA,length([email protected]$batch))
[email protected]$celltype[which([email protected]$batch=='RNA')][email protected]$celltype
DimPlot(pbmc, reduction='umap', group.by='celltype', pt.size=0.1,label=T)

Use BBKNN in Python:

Please download beer_bbknn.py.

source('https://raw.githubusercontent.com/jumphone/BEER/master/BEER.R')
#source('BEER.R')
pbmc <- mybeer$seurat
pbmc=BEER.combat(pbmc) #Adjust PCs using ComBat
PCUSE = mybeer$select
used.pca = pbmc@[email protected][,PCUSE]
.writeTable(DATA=used.pca, PATH='used.pca.txt',SEP=',')
.writeTable([email protected]$batch, PATH='batch.txt',SEP=',')

Then, use "beer_bbknn.py" in your command line (please modify parameters in beer_bbknn.py):

python beer_bbknn.py

Finally, load the output of beer_bbknn.py and draw UMAP:

umap=read.table('bbknn_umap.txt',sep='\t',header=FALSE)
umap=as.matrix(umap)
rownames(umap)=rownames(pbmc@[email protected])
colnames(umap)=colnames(pbmc@[email protected])
pbmc@[email protected]=umap
DimPlot(pbmc, reduction='umap', group.by='batch', pt.size=0.1,label=F)

VI. Transfer labels

This DEMO follows V. Batch-effect Removal Enhancement

[email protected]$celltype=rep(NA,length([email protected]$batch))
[email protected]$celltype[which([email protected]$batch=='RNA')][email protected]$celltype
#DimPlot(pbmc, reduction='umap', group.by='celltype', pt.size=0.1,label=T)

#######
VEC=pbmc@[email protected]
set.seed(123)
N=150
K=kmeans(VEC,centers=N)
[email protected]$kclust=K$cluster   
#DimPlot(pbmc, reduction='umap', group.by='kclust', pt.size=0.1,label=T)

[email protected]$transfer=rep(NA, length([email protected]$celltype))
TMP=cbind([email protected]$celltype, [email protected]$kclust)

KC=unique([email protected]$kclust)
i=1
while(i<=length(KC)){
    this_kc=KC[i]
    this_index=which([email protected]$kclust==this_kc)
    this_tb=table([email protected]$celltype[this_index])
    if(length(this_tb)!=0){
        this_ct=names(this_tb)[which(this_tb==max(this_tb))[1]]
        [email protected]$transfer[this_index]=this_ct}
    i=i+1}
    
[email protected][email protected]$celltype
NA.index=which(is.na([email protected]$celltype))
[email protected]$tf.ct[NA.index][email protected]$transfer[NA.index]

######
RNA.cells=colnames(pbmc)[which([email protected]$batch=='RNA')]
ATAC.cells=colnames(pbmc)[which([email protected]$batch=='ATAC')]

library(ggplot2)

plot.all <- DimPlot(pbmc, reduction='umap', group.by='batch', 
    pt.size=0.1,label=F) + labs(title = "Batches")

plot.ct <- DimPlot(pbmc,reduction='umap', group.by='tf.ct', 
    pt.size=0.1,label=T) + labs(title = "CellType")

plot.rna <- DimPlot(pbmc, cells=RNA.cells,reduction='umap', 
    group.by='tf.ct', pt.size=0.1,label=T,plot.title='RNA.transfer') + labs(title = "RNA")

plot.atac <- DimPlot(pbmc, cells=ATAC.cells,reduction='umap', 
    group.by='tf.ct', pt.size=0.1,label=T,plot.title='ATAC.transfer') + labs(title = "ATAC")

CombinePlots(list(all=plot.all, ct=plot.ct, rna=plot.rna, atac=plot.atac))

If you want to visualize peak signals of any given cluster, please go to https://github.com/jumphone/VISA.



VII. Biological Interpretation

Please install "RITANdata" and "RITAN".

RITAN: https://bioconductor.org/packages/devel/bioc/vignettes/RITAN/inst/doc/enrichment.html

This DEMO follows IV. Combine scATAC-seq & scRNA-seq

library(RITANdata)
library(RITAN)

PCUSE <- mybeer$select
PCALL <- c(1:length(mybeer$cor))
PCnotUSE <- PCALL[which(!PCALL %in% PCUSE)]

LD=mybeer$seurat@[email protected]
GNAME=rownames(LD)

N=100
getPosAndNegTop <- function(x){
    O=c(order(x)[1:N],order(x)[(length(x)-(N-1)):length(x)])
    G=GNAME[O]
    return(G)
    }

GMAT=apply(LD,2,getPosAndNegTop)
colnames(GMAT)=paste0(colnames(GMAT),'_R_',round(mybeer$cor,1),"_L_",round(mybeer$lcor,1))
GMAT=toupper(GMAT)

GMAT=GMAT[,PCnotUSE]
#GMAT=GMAT[,PCUSE]

study_set=list()
TAG=colnames(GMAT)
i=1
while(i<=ncol(GMAT)){
     study_set=c(study_set,list(GMAT[,i]))
     i=i+1
     }  
     
names(study_set)=TAG
#names(geneset_list)
resources=c('KEGG_filtered_canonical_pathways','MSigDB_Hallmarks')

e <- term_enrichment_by_subset( study_set, q_value_threshold = 1e-5, 
                            resources = resources,
                            all_symbols = cached_coding_genes )

plot( e, show_values = FALSE, label_size_y = 7, label_size_x = 7, cap=10 )



VIII. QC before using BEER

Download demo data: https://sourceforge.net/projects/beergithub/files/

Step1. Load Data

source('https://raw.githubusercontent.com/jumphone/BEER/master/BEER.R')

#Load Demo Data (Oligodendroglioma, GSE70630)
#Download: https://sourceforge.net/projects/beergithub/files/

D1=readRDS('MGH36.RDS')
D2=readRDS('MGH53.RDS')
D3=readRDS('MGH54.RDS')
D4=readRDS('MGH60.RDS')
D5=readRDS('MGH93.RDS')
D6=readRDS('MGH97.RDS')

BATCH=c(rep('D1',ncol(D1)),
        rep('D2',ncol(D2)),
        rep('D3',ncol(D3)),
        rep('D4',ncol(D4)),
        rep('D5',ncol(D5)),
        rep('D6',ncol(D6)) )
    
D12=.simple_combine(D1,D2)$combine
D34=.simple_combine(D3,D4)$combine
D56=.simple_combine(D5,D6)$combine
D1234=.simple_combine(D12,D34)$combine
D123456=.simple_combine(D1234,D56)$combine

DATA=D123456   

rm(D1);rm(D2);rm(D3);rm(D4);rm(D5);rm(D6)
rm(D12);rm(D34);rm(D56);rm(D1234);rm(D123456)

Step2. QC

pbmc <- CreateSeuratObject(counts = DATA, project = "pbmc3k", min.cells = 0, min.features = 0)
Idents(pbmc)=BATCH
[email protected]$batch=BATCH

pbmc <- subset(pbmc, subset = nFeature_RNA > 200 & nFeature_RNA < 2500 & percent.mt < 5)

Please fllow https://satijalab.org/seurat/v3.1/pbmc3k_tutorial.html to do Quality Control.

[email protected]$batch

DATA=as.matrix(pbmc@assays$RNA@counts[,which(colnames(pbmc@assays$RNA@counts) %in% colnames(pbmc@assays$RNA@data))])

Step3. BEER

Refer to II. Combine Multiple Batches


Reference:

Feng Zhang, Yu Wu, Weidong Tian*; A novel approach to remove the batch effect of single-cell data, Cell Discovery, 2019, https://doi.org/10.1038/s41421-019-0114-x

Differences between the latest version and the manuscript version

Latest version: https://github.com/jumphone/BEER/releases

Manuscript version: https://github.com/jumphone/BEER/archive/0.0.2.zip



License

MIT License

Copyright (c) 2019 Zhang, Feng

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].