metagenomeSeq error using plotMRheatmap and display() heatmaps and PCA/MDS plots
1
0
Entering edit mode
noelle.noyes ▴ 30
@noellenoyes-7241
Last seen 5.5 years ago
United States

I am having trouble generating heatmaps and PCA plots after using the aggTax function in metagenomeSeq.  I receive the following error:

 

Error in hclustfun(distfun(x)) : 

  NA/NaN/Inf in foreign function call (arg 11)

 

Here is the code:

 

#Aggregate data (using normalized counts); unaggregated data has 319 features and 69 samples; aggregated data has 16 features and 69 samples:

class = as.character(fData(unaggregated)[, 1])

aggregated = aggTax(MRcounts(unaggregated, norm=TRUE), lvl = class, out = "MRexperiment")

 

#Remove samples that will not cluster b/c they do not contain at least 2 features:

EmptySamples = which(colSums(MRcounts(aggregated) > 0) < 2)

aggregated = aggregated[ ,-EmptySamples]

 

#Generate heatmap (or use display()):

trials = pData(unaggregated)$Time

heatmapColColors = brewer.pal(12, "Set3")[as.integer(factor(trials))]

heatmapCols = colorRampPalette(brewer.pal(9, "RdBu"))(50)

plotMRheatmap(obj = aggregated, n = 200, cexRow = 0.4, cexCol = 0.4, trace = "none", col = heatmapCols, ColSideColors = heatmapColColors)

 

Then I get the error message (which I also receive when trying to use display()).  I've checked that the data matrix doesn't contain any samples with <2 features, so I'm not sure what is happening.  Thanks again.

metagenomseq microbiome • 1.1k views
ADD COMMENT
1
Entering edit mode
@joseph-nathaniel-paulson-6442
Last seen 4.4 years ago
United States

Hi Noelle,

If I'm reading the script above, there are actually two errors that I list below:

1) In the call to plotMRheatmap you set n = 200, but you only have 16 aggregated levels/rows. You can't display more bacteria than you have! 

2) You requested trials of the unaggregated samples, but then plot aggregated samples AFTER filtering "empty" samples. Be wary of potentially having the wrong number of column colors if you have the wrong number of samples.

The following should run:

trials = pData(unaggregated[,-EmptySamples])$Time
heatmapColColors = brewer.pal(12, "Set3")[as.integer(factor(trials))]
heatmapCols = colorRampPalette(brewer.pal(9, "RdBu"))(50)
plotMRheatmap(obj = aggregated, n = 16, cexRow = 0.4, cexCol = 0.4, trace = "none", col = heatmapCols, ColSideColors = heatmapColColors)

 

Regarding the error message with display, it appears that I set the initial number of features / rows / bacteria to 50. I've reduced it in the release/devel versions of the interactiveDisplay and it should work soon.

 

Thanks!

ADD COMMENT

Login before adding your answer.

Traffic: 438 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