Error in pheatmap 'Error in hclust(d, method = method) : must have n >= 2 objects to cluster' for selected genes
1
0
Entering edit mode
12 weeks ago

Hi all,

I'm driving myself up a wall with this one. I am looking to make a heatmap for a selected group of differential genes. I successfully created a heatmap of top 500 genes using this data with the following code:

topVarGenes <- head(order(rowVars(vst), decreasing = TRUE), 500)
mat  <- vst[ topVarGenes, ]
mat  <- mat - rowMeans(mat)
anno <- as.data.frame(colData(atacDDS)[c("Group")])
pheatmap(mat, annotation_col = anno, show_rownames=FALSE)

When I try to make a heatmap with selected genes using the following code, I get the below error:

selectGene <- c(  "ID_chr2_33134006_33135625" ,"ID_chr9_115087304_115087749", "..")
dataSub <- mat[rownames(mat) %in% selectGene, ]

pheatmap(dataSub, annotation_col = anno, labels_row =c("ID_chr2_33134006_33135625"="LTBP1", "...")

Error in hclust(d, method = method) : must have n >= 2 objects to cluster

If anyone has any suggestions I'd appreciate them!

pheatmap • 775 views
ADD COMMENT
0
Entering edit mode

This is not a direct answer to your question, but it may be helpful if you are truly "driving yourself up a wall." It seems that you are doing something wrong in selecting a subset of genes, but I can't quite see what it is.

Why don't you make a second table manually that contains only genes of interest, and then use the same code that worked above?

ADD REPLY
0
Entering edit mode

I appreciate your answer. I am going to go forward with doing that, I originally wanted to avoid it because of my dislike of organizing gene IDs on csv files, but I think it might be the cleanest way to go about it

ADD REPLY
0
Entering edit mode
12 weeks ago

The first thing to check is what dataSub looks like - how many rows and columns and if there's any NAs.

ADD COMMENT

Login before adding your answer.

Traffic: 1662 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6