pachterlab / voyager

From geospatial to spatial -omics
https://pachterlab.github.io/voyager/
Artistic License 2.0
70 stars 8 forks source link

how to change color of plotLocalResult (remain spots with p < 0.05 only) #35

Closed huiyijiangling closed 1 week ago

huiyijiangling commented 1 month ago

plotLocalResult(sfe_tissue, "LOSH.cs", features = "TP53", attribute = "-log10p_adj", colGeometryName = "spotPoly", divergent = TRUE, diverge_center = -log10(0.05), swap_rownames = "symbol", image_id = "lowres") + theme_void()



how to change color to  remain spots with p < 0.05 only.
huiyijiangling commented 1 month ago

subset spots p < 0.05 ?

lambdamoses commented 1 month ago

You can use the localResult getter to get the p-values and then subset the SFE object before plotting, something like

lr <- localResult(sfe, "LOSH.cs", "TP53")
is_sig <- lr[,"-log10p_adj"] > -log10(0.05)
sfe_sub <- sfe[,is_sig]

Though I'm not sure if only plotting spots that are significant is a good idea because the 0.05 cutoff is rather arbitrary.