## ----message=F, warning=F, results=F------------------------------------------ library(scRNAseq) lung <- ZilionisLungData() immune <- lung$Used & lung$used_in_NSCLC_immune lung <- lung[,immune] lung <- lung[,1:5000] exp.mat <- Matrix::Matrix(counts(lung),sparse = TRUE) ## ----------------------------------------------------------------------------- signatures <- list( Tcell = c("CD3D","CD3E","CD3G","CD2","TRAC"), Myeloid = c("CD14","LYZ","CSF1R","FCER1G","SPI1","LCK-"), NK = c("KLRD1","NCAM1","NKG7","CD3D-","CD3E-"), Plasma_cell = c("IGKC","IGHG3","IGHG1","IGHA1","CD19-") ) ## ----message=F, warning=F----------------------------------------------------- library(UCell) library(Seurat) seurat.object <- CreateSeuratObject(counts = exp.mat, project = "Zilionis_immune") seurat.object <- AddModuleScore_UCell(seurat.object, features=signatures, name=NULL) head(seurat.object[[]]) ## ----message=F, warning=F----------------------------------------------------- seurat.object <- NormalizeData(seurat.object) seurat.object <- FindVariableFeatures(seurat.object, selection.method = "vst", nfeatures = 500) seurat.object <- ScaleData(seurat.object) seurat.object <- RunPCA(seurat.object, npcs = 20, features=VariableFeatures(seurat.object)) seurat.object <- RunUMAP(seurat.object, reduction = "pca", dims = 1:20, seed.use=123) ## ----fig.width=9, fig.height=7, dpi=60---------------------------------------- library(ggplot2) library(patchwork) FeaturePlot(seurat.object, reduction = "umap", features = names(signatures)) ## ----------------------------------------------------------------------------- seurat.object <- SmoothKNN(seurat.object, signature.names = names(signatures), reduction="pca") ## ----fig.wide=TRUE, dpi=60---------------------------------------------------- FeaturePlot(seurat.object, reduction = "umap", features = c("NK","NK_kNN")) ## ----------------------------------------------------------------------------- genes <- c("CD2","CSF1R") expr <- Seurat::GetAssayData(seurat.object, assay="RNA", slot="data")[genes,] expr <- t(as.matrix(expr)) seurat.object <- AddMetaData(seurat.object, metadata=as.data.frame(expr)) ## ----warning=FALSE, fig.width=9, fig.height=7, dpi=60------------------------- seurat.object <- SmoothKNN(seurat.object, signature.names=genes, reduction="pca", k=20, suffix = "_smooth") FeaturePlot(seurat.object, reduction = "umap", features = c("CD2","CD2_smooth","CSF1R","CSF1R_smooth")) ## ----------------------------------------------------------------------------- sessionInfo()