The package scutilsR is my code hub for utilities in scRNA-seq
analysis.
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")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 matrixMark 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.
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)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 listcollected 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)DefaultAssay(seu) <- "RNA"
seu <- impute_nmf(seu, min_cells = 50, k = 100, threads = 10, seed = 1024)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)