Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add plot_lisa_feature #34

Merged
merged 6 commits into from
Sep 6, 2024
Merged

add plot_lisa_feature #34

merged 6 commits into from
Sep 6, 2024

Conversation

xiangpin
Copy link
Member

@xiangpin xiangpin commented Sep 5, 2024

add plot_lisa_feature to simplify the visualization of LISA result.

library(ggplot2)
library(SingleCellExperiment) |> suppressPackageStartupMessages()
library(SpatialExperiment) |> suppressPackageStartupMessages()
library(STexampleData)
# create ExperimentHub instance
eh <- ExperimentHub()
# query STexampleData datasets
myfiles <- query(eh, "STexampleData")
ah_id <- myfiles$ah_id[myfiles$title == 'Visium_humanDLPFC']
spe <- myfiles[[ah_id]]
spe <- spe[, colData(spe)$in_tissue == 1]
spe <-scater::logNormCounts(spe)
genes <- c('MOBP', 'PCP4', 'SNAP25', 'HBB', 'IGKC', 'NPY')
target.features <- rownames(spe)[match(genes, rowData(spe)$gene_name)]
library(SVP)
lisa.res1 <- runLISA(spe,
                     assay.type='logcounts',
                     features=target.features[seq(2)],
                     weight.method='knn',
                     k=50)
library(ggsc)
plot_lisa_feature(spe, lisa.res=lisa.res1, features=target.features[seq(2)],
                  pointsize=2, hlpointsize=2, gap_line_width=.1)
}

image


library(Seurat)
pbmc <- readRDS("./pbmc_seurat.rds")

features = c("MS4A1", "GNLY", "CD3E",
            "CD14", "FCER1A", "FCGR3A",
            "LYZ", "PPBP", "CD8A")

sce.pbmc <- as.SingleCellExperiment(pbmc)
library(SVP)
lisa.res2 <- runLISA(sce.pbmc, assay.type='logcounts', features = features,
                     reduction.used='UMAP', weight.method='knn', k=50)

plot_lisa_feature(sce.pbmc, lisa.res2, pointsize=.8, hlpointsize=.6, reduction='UMAP')

image

@GuangchuangYu GuangchuangYu merged commit 3281647 into YuLab-SMU:devel Sep 6, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants