LieberInstitute / spatialDLPFC

spatialDLPFC project involving Visium (n = 30), Visium SPG (n = 4) and snRNA-seq (n = 19) samples
http://research.libd.org/spatialDLPFC/
17 stars 3 forks source link

Fix Spatial Plot Dimensions #135

Closed lahuuki closed 1 year ago

lahuuki commented 1 year ago

Some spot plots created by spatialLIBD::vis_gene() of samples are forced out of the correct aspect ratio when saved to pdfs. This is because the image is often not a square. However the fiducial frame (large dots on edge) are. For individual plots this can be fixed by using coord_fixed and exporting with ggsave (don't specify dimensions)

vis_gene_test <- vis_gene(
  spe = spe,
  point_size = 1.2,
  sampleid = "Br6522_ant",
  geneid = "CLDN5"
) + coord_fixed()

ggsave(vis_gene_test, filename = here(plot_dir, "vis_gene_ggsave.png"))

However when we want to plot all 30 samples, this is makes things complicated because the plots now have irregular dimensions. If we limit the plots to the fiducial frame, we can get regular square areas for each sample. We can access these limits from the spaceRanger output, we'll try to acces them from these files:spatialDLPFC/processed-data/rerun_spaceranger/SAMPLE/outs/spatial/tissue_positions_list.csv

Related to https://jhu-genomics.slack.com/archives/C01EA7VDJNT/p1670009703418879

Co-authored-by: Nick Eagles nick.eagles@libd.org Co-authored-by: Heena Divecha heenadivecha@gmail.com

lahuuki commented 1 year ago

vis_gene_ggsave Space ranger min max values * scaleFactor work to find edge of frame