Reputation: 107
I am trying to create a pheatmap from the pairwise comparisions of a DESEq object, but I want that the labels of rows and columns are related to the metadata, not to be sample names.
Experiment set-up: I simply have 3 different cell types with 3 replicates each Goal: make a heatmap where these cell types cluster according to the pairwise correlation values
What I have done so far and how my data looks like:
Data frame with sample information:
> sample_info[,1:3]
Sample Cell_type Treatment
AM1 AM1 Alveolar_macrophages healthy
AM2 AM2 Alveolar_macrophages healthy
AM3 AM3 Alveolar_macrophages healthy
IM1 IM1 Interstitial_macrophages healthy
IM2 IM2 Interstitial_macrophages healthy
IM3 IM3 Interstitial_macrophages healthy
T1 T1 T_cells healthy
T2 T2 T_cells healthy
T3 T3 T_cells healthy
Data frame with read counts:
> head(only_counts)
AM1 AM2 AM3 IM1 IM2 IM3 T1 T2 T3
let-7a-1-3p 1383 930 1321 621 734 347 325 355 911
let-7a-2-3p 0 0 0 1 1 4 0 0 0
let-7a-5p 396731 293379 408655 177221 165887 152788 295030 331667 457912
let-7b-3p 40 24 23 151 172 87 81 140 170
let-7b-5p 5889 3051 2353 16342 15507 10990 31974 30384 34134
let-7c-1-3p 4 2 0 103 83 65 0 0 0
DESEq object:
dds <- DESeqDataSetFromMatrix(countData = only_counts,
colData = sample_info,
design= ~ Cell_type)
Transformations and calculations:
vsd <- varianceStabilizingTransformation(dds, blind=T)
vsd_mat <- assay(vsd) #extract the vst matrix
vsd_cor <- cor(vsd_mat) #compute pairwise correlation values
Heatmap
pheatmap(vsd_cor,
main="Hierarchical clustering",
annotation = colData(dds)$Cell_type)
Error in `[.default`(annotation_col, colnames(mat), , drop = F) :
incorrect number of dimensions
When I do the simple heatmap:
pheatmap(vsd_cor,
main="Hierarchical clustering")
But I want that instead of sample names, cell type is displayed (colData(dds)$Cell_type)
I have tried similar things but none worked:
pheatmap(vsd_cor,
annotation = sample_info$Cell_type)
pheatmap(vsd_cor,
annotation_col = colData(dds)$Cell_type,
annotation_row=colData(dds)$Cell_type)
pheatmap(vsd_cor,
annotation_col = sample_info$Cell_type,
annotation_row=sample_info$Cell_type)
Upvotes: 1
Views: 577
Reputation: 107
In case someone has the same question, I figured it out: After getting the correlation matrix:
rownames(vsd_cor) <- paste(sample_info$Cell_type)
colnames(vsd_cor) <- paste(sample_info$Cell_type)
pheatmap(vsd_cor,
main="Hierarchical clustering")
Upvotes: 1