Run tf-idf on single-cell data
run_tfidf( object = NULL, reduction = "UMAP", label_var = "label", cluster_var = "seurat_clusters", replace_regex = "[.]|[_]|[-]", terms_per_cluster = 3, force_new = F, return_all_results = F, verbose = T )
object | Single-cell data object. Can be in |
---|---|
reduction | Name of the reduction to use (case insensitive). |
label_var | Which cell metadata column to input to tf-idf enrichment analysis. |
cluster_var | Which cell metadata column to use to identify which cluster each cell is assigned to. |
replace_regex | Characters by which to split |
terms_per_cluster | The number of top significantly enriched terms to include per cluster. |
force_new | If tf-idf results are already detected the metadata, set |
return_all_results | Whether to return just the |
verbose | Whether to print messages. |
library(scNLP) data("pseudo_seurat") pseudo_seurat_tfidf <- run_tfidf(object = pseudo_seurat, reduction = "UMAP", cluster_var = "cluster", label_var = "celltype")#> [1] "+ Extracting data from Seurat object." #> [1] "+ Using reduction: umap"#>#>#>#> cluster batch species dataset celltype label #> human.DRONC_human.ASC1 5 DRONC_human human DRONC_human ASC1 ASC1 #> human.DRONC_human.ASC2 5 DRONC_human human DRONC_human ASC2 ASC2 #> human.DRONC_human.END 9 DRONC_mouse mouse DRONC_mouse END END #> human.DRONC_human.exCA1 0 DRONC_human human DRONC_human exCA1 exCA1 #> human.DRONC_human.exCA3 0 DRONC_human human DRONC_human exCA3 exCA3 #> human.DRONC_human.exDG 0 DRONC_human human DRONC_human exDG exDG #> nCount_RNA nFeature_RNA RNA_snn_res.0.8 seurat_clusters #> human.DRONC_human.ASC1 237.9283 671 5 5 #> human.DRONC_human.ASC2 232.7748 638 5 5 #> human.DRONC_human.END 288.9631 616 9 9 #> human.DRONC_human.exCA1 245.1858 669 0 0 #> human.DRONC_human.exCA3 225.1575 675 0 0 #> human.DRONC_human.exDG 237.8823 678 0 0 #> UMAP_1 UMAP_2 enriched_words #> human.DRONC_human.ASC1 -0.4796632 0.17629431 glia; schwann; radial #> human.DRONC_human.ASC2 -0.6386602 -0.05231967 glia; schwann; radial #> human.DRONC_human.END -7.7066403 -1.84134831 vascular; peric; pericytes #> human.DRONC_human.exCA1 6.2326443 1.51104526 lpn; adpn; neuron #> human.DRONC_human.exCA3 6.0303471 1.47096417 lpn; adpn; neuron #> human.DRONC_human.exDG 5.9316036 1.49563257 lpn; adpn; neuron #> tf_idf #> human.DRONC_human.ASC1 0.198360552120631; 0.181900967132288; 0.111766521696813 #> human.DRONC_human.ASC2 0.198360552120631; 0.181900967132288; 0.111766521696813 #> human.DRONC_human.END 0.528096815017439; 0.042313284392222 #> human.DRONC_human.exCA1 0.0527542246967963; 0.0523351433907082; 0.0428030761818744 #> human.DRONC_human.exCA3 0.0527542246967963; 0.0523351433907082; 0.0428030761818744 #> human.DRONC_human.exDG 0.0527542246967963; 0.0523351433907082; 0.0428030761818744