<- rna_integrated@assays$RNA@data[c("MIPOL1", "ETV1", "DGKB", "FOXA2", "AR", "SYP"),] %>% as.matrix() %>% t()
cell_expression <- rna_integrated@meta.data
meta_data <- cbind(meta_data, cell_expression)
plot_data saveRDS(plot_data, "scRNAseq_violin.RDS")
5 Single-Cell Analysis
Most of these code are reliant on Seurat. You may now and then have to use scanpy in python, or revert to the SingleCellExperiment object utilized in scater.
5.1 Useful links and resources
Fine-tuning UMAP visualizations https://jlmelville.github.io/uwot/abparams.html
TSNE animation https://distill.pub/2016/misread-tsne/
Simple explanantion on TSNE https://www.cancer.gov/about-nci/organization/ccg/blog/2020/interview-t-sne
Different integration methods https://swaruplab.bio.uci.edu/tutorial/integration/integration_tutorial.html
Illustration of how UMAPs can be misleading https://pair-code.github.io/understanding-umap/ https://blog.bioturing.com/2022/01/14/umap-vs-t-sne-single-cell-rna-seq-data-visualization/
Single cell best practices from the Theis lab https://www.sc-best-practices.org/preamble.html https://broadinstitute.github.io/2019_scWorkshop/index.html
Deep explanation of Seurat’s AddModuleScore function https://www.waltermuskovic.com/2021/04/15/seurat-s-addmodulescore-function/
5.1.1 Psudotime analysis
https://broadinstitute.github.io/2019_scWorkshop/functional-pseudotime-analysis.html
List of single cell pseudotime packages publishe#d https://github.com/agitter/single-cell-pseudotime
5.1.2 Spatial Transciptomics
5.1.3 Downloading data
bam files uploaded to SRA will be missing certain 10x flags and will not work. You need to get the original bam files via SRA Data Access Tab and downloaded via wget and run bamtofastq.
for 10x, need to use –split-filles and –include-technical.
5.1.4 CellRanger
5.2 Seurat
5.2.1 Integration
- applying sctransform to each sample in the list
- selecting integration features,
- finding integration anchors,
- integrate data at this point, DefaultAssay is integrated, and there is an associated VariableFeatures, which really is output of SelectIntegrationFetures. rownames(integrated[[“SCT”]](scale.data?)) is the same as SelectIntegration Features again.
https://github.com/satijalab/seurat/issues/6185 explanation of the different variable gene options from sct integrated models
After merge()
variable features that have been calculated by SCTransform is reset.
5.2.2 Plotting
Use scCustomize for improved plotting over Seurat’s defaults.
To plot heatmaps with extra metadata information, use the scillius package.
To get statistics on differential gene levels, use the package ggbetweenstats
from ggstatsplot.
5.2.3 Utility functions
Renaming all identities
<- c("0" = "", "1" = "", "2" = "", "3" = "", "4" = "", "5" = "", "6" = "")
cell_types Idents(merged) <- "SCT_snn_res.0.2"
<- RenameIdents(merged, cell_types)
merged $status <- Idents(merged)
mergedDimPlot_scCustom(integrated, group.by = "cell_types", colors_use = polychrome_pal)
$status <- factor(merged$status,
mergedlevels = c("")) # useful for rearranging levels
Idents(merged) <- "status"
Renaming a few identities
<- case_when(seu_obj$clust == "a" ~ "Tumor",
new_groups .default = seu_obj$clust) %>% as.factor()
names(new_groups) <- names(seu_obj$clust)
$new_groups <- new_groups
seu_obj$new_groups <- factor(seu_obj$new_groups,
seu_objlevels = c("")) # have to do this again
Adding new clusters, cluster 13 was not present previously
$manual_clusters <- seu_obj$integrated_snn_res.0.6
seu_objlevels(seu_obj$manual_clusters) <- c(levels(seu_obj$manual_clusters), "13")
$manual_clusters[names(seu_obj$manual_clusters) %in% select_cells] <- "13" seu_obj