-
Notifications
You must be signed in to change notification settings - Fork 0
4_Data visualization
Olivia Waltner edited this page Apr 18, 2023
·
8 revisions
Our package viewmastR provides a helpful function to generate beautiful and distinct colors quickly.
cluster_cols <- viewmastR::sfc(n=10, scramble = F)
We typically use these color palettes for different assays
rna_cols <- paletteContinuous(n=8)[c(1:3, 6:8)]
atac_cols <- paletteContinuous(set = "blueYellow")
pal<- rev(mako(n=9))
pal<-pal[1:8]
pal<-c("#ffffff", pal)
chromvar_cols<-pal
adt_cols <- paletteContinuous(set = "whiteBlue")
pseudotime_cols<- viridis::plasma(n=10)
tcr_cols <- c("gray90", rev(brewer.spectral(n =5)))
t <-BuenColors::jdb_palette("brewer_spectra")
multiome_cols <- c(t[2],t[3], "#e5e6e1", t[7],t[9])
Heatmaps are widely used to present matrix based data. Seurat and monocle do not provide simple methods to create heat maps, all though they are frequently used in publications. Below are tutorials and example code for single cell and pseudobulk heat maps.
seu_avg<-AverageExpression(seurat_object, assay ="RNA", group.by = "seurat_clusters")
#subset by genes you want to look at
genes<-c("Foxp3", "Tcf7", "Tbx21")
mat <- seu_avg[[1]][genes,] %>% as.matrix()
mat<- t(scale(t(mat)))
h_cols <-rev(brewer.pal(name = "RdYlBu", n = 7))
quantile(mat, c(0.1, 0.2, 0.4, 0.5, 0.6, 0.8, 0.9))
col_fun = circlize::colorRamp2(quantile(mat, c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9)), h_cols)
Heatmap(mat, name = "RNA", col =col_fun, row_names_gp = gpar(fontsize = 12), column_names_gp = gpar(fontsize = 16), column_names_rot = -90, cluster_columns =T, width = 100, cluster_rows = T, show_column_dend = T, show_row_dend = T)
We use them all the time to show cell type frequency across datasets/experimental conditions/time points/etc.
df<- data.frame(table(seu$cell_type, seu$condition))
ggplot(df, aes(fill = Var1, y=Freq, x=Var2)) +
geom_bar(stat = "identity", position = "fill")+scale_fill_manual(values = clus_cols)+theme_classic()+RotatedAxis()+NoGrid()