You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to generate spatial plots for a dataset that combines samples from 3 different projects (p21, adult, aged). When creating spatial plots, different point sizes need to be used for each sample. I would like to look at gene expression across all samples, but using the merged dataset, this means generating each plot 3 times for the 3 point sizes, and then using editing software to create a combined image. When looking at a lot of genes, this takes a lot of time. I've tried to subset the data, but then the scales are different in each plot, which makes cross-sample interpretation impossible. Does anyone have any ideas? Here is one iteration of the code. Note that I've tried all 3 options for keep.scale: "feature", "all", and NULL.
`#Define the minimum and maximum quartiles for the plots
global_min = "q05"
global_max = "q95"
for (gene_to_examine in gene_vector) {
adult_img<-SpatialFeaturePlot(adult_subset, features = gene_to_examine, keep.scale=NULL,
min.cutoff = global_min,
max.cutoff = global_max,
pt.size.factor = 2)
uniform_scale <- scale_fill_gradientn(
colors = rev(RColorBrewer::brewer.pal(n=5, name = "YlGnBu")), # Use a consistent color palette
limits = c(global_min, global_max) # Apply the global min and max limits
)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to generate spatial plots for a dataset that combines samples from 3 different projects (p21, adult, aged). When creating spatial plots, different point sizes need to be used for each sample. I would like to look at gene expression across all samples, but using the merged dataset, this means generating each plot 3 times for the 3 point sizes, and then using editing software to create a combined image. When looking at a lot of genes, this takes a lot of time. I've tried to subset the data, but then the scales are different in each plot, which makes cross-sample interpretation impossible. Does anyone have any ideas? Here is one iteration of the code. Note that I've tried all 3 options for keep.scale: "feature", "all", and NULL.
`#Define the minimum and maximum quartiles for the plots
global_min = "q05"
global_max = "q95"
for (gene_to_examine in gene_vector) {
adult_img<-SpatialFeaturePlot(adult_subset, features = gene_to_examine, keep.scale=NULL,
min.cutoff = global_min,
max.cutoff = global_max,
pt.size.factor = 2)
p21_img<-SpatialFeaturePlot(p21_subset, features = gene_to_examine, keep.scale=NULL,
min.cutoff = global_min,
max.cutoff = global_max,
pt.size.factor = 475)
aged_img<-SpatialFeaturePlot(aged_subset, features = gene_to_examine, keep.scale=NULL,
min.cutoff = global_min,
max.cutoff = global_max,
pt.size.factor = 3)
uniform_scale <- scale_fill_gradientn(
colors = rev(RColorBrewer::brewer.pal(n=5, name = "YlGnBu")), # Use a consistent color palette
limits = c(global_min, global_max) # Apply the global min and max limits
)
#uses patchwork, a Seurat function
combined_img <- (p21_img | adult_img | aged_img) + plot_layout(ncol = 1, nrow = 3)
ggsave(paste0("./Figures/Spatial_Gene/", gene_to_examine, "_combined.png"), height = 12, width = 6, units = 'in')
#ncol = 1 b/c each image (containing 2 samples) is a single image; need to define both ncol & nrow or won't run.
print(combined_img)
}`
Beta Was this translation helpful? Give feedback.
All reactions