Skip to content

JarningGau/scutilsR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scutilsR

Project Status: Active - The project has reached a stable, usable state and is being actively developed.

The package scutilsR is my code hub for utilities in scRNA-seq analysis.

Installation

You can install the development version of scutilsR from GitHub with:

# install.packages("devtools")
# install DoubletFinder
devtools::install_github("chris-mcginnis-ucsf/DoubletFinder", ref = "554097b")
# install CellChat
devtools::install_github("sqjin/CellChat", ref = "418b660")
devtools::install_github("JarningGau/scutilsR")

Example

IO

Read output from STARsolo

Elife_2019_mouse_GSE113293/ # sample hub: contains a list of samples
├── GSM3102982              # sample ID:  contains a list of assays
│   ├── corrected
│   │   ├── barcodes.tsv
│   │   ├── decontX.info.tsv
│   │   ├── features.tsv
│   │   └── matrix.mtx.gz
│   ├── filtered            # output of STARsolo after cell calling
│   │   ├── barcodes.tsv
│   │   ├── features.tsv
│   │   └── matrix.mtx.gz
│   └── raw                 # output of STARsolo before cell calling
│       ├── barcodes.tsv
│       ├── features.tsv
│       └── matrix.mtx.gz
mm <- ReadSolo(path = "/path/to/samplehub", assay = "assay")

Read output from DNBelab C4 pipeline

data <- ReadC4("/path/to/dnbc4.txt.gz") # C4 output is a compressed dense matrix

Doublets Removal

Mark doublets rather than remove them via DoubletFinder.

MarkDoublets() function run DoubletsFinder separately. All parameters for DoubletsFinder are default.

  • pK: auto selected by FindOptimalpK()
  • pN: 0.25
  • estimated percentage of doublets: 0.075
seu <- MarkDoublets(seu = seu, PCs = 1:10, split.by = "orig.ident")

Users can remove the marked doublets or clusters enriched marked doublets.

Remove Ambient RNAs & Calculate Contimination Rates

If you have the clusters information.

seu <- RemoveAmbientRNAs(seu, split.by = "orig.ident", cluster.name = "seurat_clusters")

else

seu <- RemoveAmbientRNAs(seu, split.by = "orig.ident", cluster.name = NULL)

Find All Markers Parallelly

all.markers <- mcFindAllMarkers(seu = seu, do.flatten = T, only.pos = T, n.cores = 10) # returns a data.frame
all.markers <- mcFindAllMarkers(seu = seu, do.flatten = F, only.pos = T, n.cores = 10) # returns a list

Annotate Cell Types According to Markers via Enrichment Analysis

collected gene sets

all.markers <- mcFindAllMarkers(seu.ds, do.flatten = F, only.pos = T, n.cores = 20)
all.markers <- lapply(all.markers, function(xx) subset(xx, p_val_adj < 1e-10 & avg_log2FC > log2(2))$Gene.name.uniq)

## enrichment analysis (human)
data("mca_hsa")
data("hcl_hsa")
t2g <- rbind(mca_hsa, hcl_hsa)

e.res <- enrich_batch(all.markers, t2g)
enrich_dotplot(e.res)

Data Imputation

DefaultAssay(seu) <- "RNA"
seu <- impute_nmf(seu, min_cells = 50, k = 100, threads = 10, seed = 1024)

Cell-Cell Communication

A CellChat wrapper CellChatHelper() was implemented in scutilsR

DB <- subsetDB(CellChat::CellChatDB.human, search = "Secreted Signaling")

# outputs:
# - {out.dir}/cellchat.{name}.{mode}.rds
# - {out.dir}/cellchat.{name}.{mode}.pdf

CellChatHelper(seu = seu, 
               label.field = "seurat_clusters", 
               name = "run_name", 
               mode = "default", 
               DB = DB, 
               out.dir = getwd(), 
               cores = 10, 
               fig.width = 10, 
               fig.height = 8)

About

No description, website, or topics provided.

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages