SS <- readRDS("../0-Seurat_RDS_OBJECT_FINAL/Seurat_object_Final_changes/All_samples_Merged_with_STCAT_Annotation_final-5-09-2025.rds")
# Subset SS for cell line L2
SS_L2 <- subset(SS, subset = cell_line == "L2")
rm(SS)
library(reticulate)
use_virtualenv("/home/bioinfo/.virtualenvs/r-reticulate", required=TRUE)
py_config()
python: /home/bioinfo/.virtualenvs/r-reticulate/bin/python
libpython: /usr/lib/python3.12/config-3.12-x86_64-linux-gnu/libpython3.12.so
pythonhome: /home/bioinfo/.virtualenvs/r-reticulate:/home/bioinfo/.virtualenvs/r-reticulate
version: 3.12.3 (main, Aug 14 2025, 17:47:21) [GCC 13.3.0]
numpy: /home/bioinfo/.virtualenvs/r-reticulate/lib/python3.12/site-packages/numpy
numpy_version: 1.26.4
NOTE: Python version was forced by use_python() function
py_module_available("magic")
[1] TRUE
library(scATOMIC)
library(plyr)
library(dplyr)
library(data.table)
library(randomForest)
library(caret)
library(parallel)
library(reticulate)
library(Rmagic)
library(Matrix)
library(Seurat)
library(agrmt)
library(cutoff.scATOMIC)
library(copykat)
library(ggplot2)
DefaultAssay(SS_L2) <- "RNA"
library(Matrix)
# Example: subsetting L2 but keeping all individual cells
sparse_matrix_L2 <- GetAssayData(SS_L2, assay = "RNA", slot = "counts")
# Remove genes with zero counts
nonzero_genes <- rowSums(sparse_matrix_L2) > 0
sparse_matrix_L2_filtered <- sparse_matrix_L2[nonzero_genes, ]
# Run scATOMIC
cell_predictions_L2 <- run_scATOMIC(sparse_matrix_L2_filtered)
[1] "Starting Layer 1"
[1] "Done Layer 1"
[1] "Starting Layer 2 Non Blood"
[1] "Done Layer 2 Non Blood"
[1] "Starting Layer 3 Non Stromal"
[1] "Done Layer 3 Non Stromal"
[1] "Starting Layer 4 Non GI"
[1] "Done Layer 4 Non GI"
[1] "Starting Layer 5 Breast Lung Prostate"
[1] "nothing to score in this layer"
[1] "Done Layer 5 Breast Lung Prostate"
[1] "Starting Layer 2 Blood"
[1] "Done Layer 2 Blood"
[1] "Starting Layer 3 TNK"
[1] "Done Layer 3 TNK"
[1] "Starting Layer 4 CD4 CD8"
[1] "nothing to score in this layer"
[1] "Done Layer 4 CD4 CD8"
[1] "Starting Layer 4 CD8 NK"
[1] "nothing to score in this layer"
[1] "Done Layer 4 CD8 NK"
[1] "Starting Layer 5 CD4"
[1] "nothing to score in this layer"
[1] "Done Layer 5 CD4"
[1] "Starting Layer 5 CD8"
[1] "nothing to score in this layer"
[1] "Done Layer 5 CD8"
# Inspect top predictions
head(cell_predictions_L2)
$layer_1
$layer_2_non_blood
$layer_3_non_stromal
$layer_4_non_GI
$layer_5_breast_lung_prostate
$layer_2_blood
NA
SS <- create_summary_matrix(prediction_list = cell_predictions_L2, use_CNVs = F, modify_results = T, mc.cores = 1, raw_counts = sparse_matrix_L2, min_prop = 0.5 )
|
| | 0%
|
|= | 0%
|
|= | 1%
|
|== | 2%
|
|=== | 2%
|
|=== | 3%
|
|==== | 3%
|
|==== | 4%
|
|===== | 4%
|
|===== | 5%
|
|====== | 5%
|
|====== | 6%
|
|======= | 6%
|
|======= | 7%
|
|======== | 7%
|
|======== | 8%
|
|========= | 8%
|
|========= | 9%
|
|========== | 9%
|
|========== | 10%
|
|=========== | 10%
|
|=========== | 11%
|
|============ | 11%
|
|============ | 12%
|
|============= | 12%
|
|============= | 13%
|
|============== | 13%
|
|============== | 14%
|
|=============== | 14%
|
|=============== | 15%
|
|================ | 15%
|
|================ | 16%
|
|================= | 16%
|
|================= | 17%
|
|================== | 17%
|
|================== | 18%
|
|=================== | 18%
|
|=================== | 19%
|
|==================== | 19%
|
|==================== | 20%
|
|===================== | 20%
|
|===================== | 21%
|
|====================== | 21%
|
|====================== | 22%
|
|======================= | 22%
|
|======================= | 23%
|
|======================== | 23%
|
|======================== | 24%
|
|========================= | 24%
|
|========================= | 25%
|
|========================== | 25%
|
|========================== | 26%
|
|=========================== | 26%
|
|=========================== | 27%
|
|============================ | 27%
|
|============================ | 28%
|
|============================= | 28%
|
|============================= | 29%
|
|============================== | 29%
|
|============================== | 30%
|
|=============================== | 30%
|
|=============================== | 31%
|
|================================ | 31%
|
|================================ | 32%
|
|================================= | 32%
|
|================================= | 33%
|
|================================== | 33%
|
|================================== | 34%
|
|=================================== | 34%
|
|=================================== | 35%
|
|==================================== | 35%
|
|==================================== | 36%
|
|===================================== | 36%
|
|===================================== | 37%
|
|====================================== | 37%
|
|====================================== | 38%
|
|======================================= | 38%
|
|======================================= | 39%
|
|======================================== | 39%
|
|======================================== | 40%
|
|========================================= | 40%
|
|========================================= | 41%
|
|========================================== | 41%
|
|========================================== | 42%
|
|=========================================== | 42%
|
|=========================================== | 43%
|
|============================================ | 43%
|
|============================================ | 44%
|
|============================================= | 44%
|
|============================================= | 45%
|
|============================================== | 45%
|
|============================================== | 46%
|
|=============================================== | 46%
|
|=============================================== | 47%
|
|================================================ | 47%
|
|================================================ | 48%
|
|================================================= | 48%
|
|================================================== | 49%
|
|================================================== | 50%
|
|=================================================== | 50%
|
|==================================================== | 50%
|
|==================================================== | 51%
|
|===================================================== | 52%
|
|====================================================== | 52%
|
|====================================================== | 53%
|
|======================================================= | 53%
|
|======================================================= | 54%
|
|======================================================== | 54%
|
|======================================================== | 55%
|
|========================================================= | 55%
|
|========================================================= | 56%
|
|========================================================== | 56%
|
|========================================================== | 57%
|
|=========================================================== | 57%
|
|=========================================================== | 58%
|
|============================================================ | 58%
|
|============================================================ | 59%
|
|============================================================= | 59%
|
|============================================================= | 60%
|
|============================================================== | 60%
|
|============================================================== | 61%
|
|=============================================================== | 61%
|
|=============================================================== | 62%
|
|================================================================ | 62%
|
|================================================================ | 63%
|
|================================================================= | 63%
|
|================================================================= | 64%
|
|================================================================== | 64%
|
|================================================================== | 65%
|
|=================================================================== | 65%
|
|=================================================================== | 66%
|
|==================================================================== | 66%
|
|==================================================================== | 67%
|
|===================================================================== | 67%
|
|===================================================================== | 68%
|
|====================================================================== | 68%
|
|====================================================================== | 69%
|
|======================================================================= | 69%
|
|======================================================================= | 70%
|
|======================================================================== | 70%
|
|======================================================================== | 71%
|
|========================================================================= | 71%
|
|========================================================================= | 72%
|
|========================================================================== | 72%
|
|========================================================================== | 73%
|
|=========================================================================== | 73%
|
|=========================================================================== | 74%
|
|============================================================================ | 74%
|
|============================================================================ | 75%
|
|============================================================================= | 75%
|
|============================================================================= | 76%
|
|============================================================================== | 76%
|
|============================================================================== | 77%
|
|=============================================================================== | 77%
|
|=============================================================================== | 78%
|
|================================================================================ | 78%
|
|================================================================================ | 79%
|
|================================================================================= | 79%
|
|================================================================================= | 80%
|
|================================================================================== | 80%
|
|================================================================================== | 81%
|
|=================================================================================== | 81%
|
|=================================================================================== | 82%
|
|==================================================================================== | 82%
|
|==================================================================================== | 83%
|
|===================================================================================== | 83%
|
|===================================================================================== | 84%
|
|====================================================================================== | 84%
|
|====================================================================================== | 85%
|
|======================================================================================= | 85%
|
|======================================================================================= | 86%
|
|======================================================================================== | 86%
|
|======================================================================================== | 87%
|
|========================================================================================= | 87%
|
|========================================================================================= | 88%
|
|========================================================================================== | 88%
|
|========================================================================================== | 89%
|
|=========================================================================================== | 89%
|
|=========================================================================================== | 90%
|
|============================================================================================ | 90%
|
|============================================================================================ | 91%
|
|============================================================================================= | 91%
|
|============================================================================================= | 92%
|
|============================================================================================== | 92%
|
|============================================================================================== | 93%
|
|=============================================================================================== | 93%
|
|=============================================================================================== | 94%
|
|================================================================================================ | 94%
|
|================================================================================================ | 95%
|
|================================================================================================= | 95%
|
|================================================================================================= | 96%
|
|================================================================================================== | 96%
|
|================================================================================================== | 97%
|
|=================================================================================================== | 97%
|
|=================================================================================================== | 98%
|
|==================================================================================================== | 98%
|
|===================================================================================================== | 99%
|
|===================================================================================================== | 100%
|
|======================================================================================================| 100%
|
| | 0%
|
|=================================================== | 50%
|
|======================================================================================================| 100%
[1] "Added MAGIC output to MAGIC_RNA. To use it, pass assay='MAGIC_RNA' to downstream methods or set seurat_object@active.assay <- 'MAGIC_RNA'."
[1] "Added MAGIC output to MAGIC_RNA. To use it, pass assay='MAGIC_RNA' to downstream methods or set seurat_object@active.assay <- 'MAGIC_RNA'."
[1] "Added MAGIC output to MAGIC_RNA. To use it, pass assay='MAGIC_RNA' to downstream methods or set seurat_object@active.assay <- 'MAGIC_RNA'."
[1] "Added MAGIC output to MAGIC_RNA. To use it, pass assay='MAGIC_RNA' to downstream methods or set seurat_object@active.assay <- 'MAGIC_RNA'."
[1] "Added MAGIC output to MAGIC_RNA. To use it, pass assay='MAGIC_RNA' to downstream methods or set seurat_object@active.assay <- 'MAGIC_RNA'."
[1] "Added MAGIC output to MAGIC_RNA. To use it, pass assay='MAGIC_RNA' to downstream methods or set seurat_object@active.assay <- 'MAGIC_RNA'."
[1] "Added MAGIC output to MAGIC_RNA. To use it, pass assay='MAGIC_RNA' to downstream methods or set seurat_object@active.assay <- 'MAGIC_RNA'."
[1] "Sample classification confidence = 0.33"
table(SS$scATOMIC_pred)
Blood Cell CD4 or CD8 T cell CD8+ T cell
678 189 33
Effector/Memory CD4+ T cells Effector/Memory CD8+ T cells Lung Cancer Cell
3931 1051 4
Naive CD4+ T cells Normal Tissue Cell T regulatory cells
17 7 25
SS_L2 <- AddMetaData(SS_L2, SS)
DimPlot(SS_L2, group.by = "scATOMIC_pred") + ggtitle("L2 from Cell lines") + labs(fill="scATOMIC Annotations")
NA
NA
All_cell_Lines <- readRDS("../0-Seurat_RDS_OBJECT_FINAL/Seurat_object_Final_changes/All_samples_Merged_with_STCAT_Annotation_final-5-09-2025.rds")
All_cell_Lines <- AddMetaData(All_cell_Lines, SS)
DimPlot(All_cell_Lines, group.by = "scATOMIC_pred") + ggtitle("L2 from Cell lines") + labs(fill="scATOMIC Annotations")
NA
NA