zellerlab / siamcat

R package for Statistical Inference of Associations between Microbial Communities And host phenoType
https://siamcat.embl.de/
52 stars 16 forks source link

model.interpretation.plot function with heatmap.type = 'fc' #25

Closed adehman closed 3 years ago

adehman commented 3 years ago

Hi SIAMCAT Team,

I want to plot the fold-change heatmap on my prediction results object using the function model.interpretation.plot. I use the following code:

model.interpretation.plot( predLasso, fn.plot = "toto.pdf", consens.thres = 0.5, max.show = 15, limits = c(-2, 2), heatmap.type = 'fc' )

But I obtain the following error:

"Error in seq.default(round(min(img.data, na.rm = TRUE), digits = 1), round(max(img.data, : 'from' must be a finite number"

When looking deeper in the code, I see that the object sel.idx calculated using model.interpretation.select.features function is unnamed and thus, it is the following code line (within model.interpretation.plot function) that creates the error:

img.data <- model.interpretation.prepare.heatmap.fc(heatmap.data = feat[, srt.idx], sel.feat = names(sel.idx), limits = limits, meta = meta(siamcat), label = label, detect.lim = detect.lim, verbose = verbose)

Is it a code mistake from my part that I should fix or is it an issue of model.interpretation.plot function ?

Thanks in advance for your help. And above all, thanks for this amazing R toolbox !

jakob-wirbel commented 3 years ago

Hi @adehman Thank you for spotting this bug!!! (it was definitely a bug, not a problem on your side!) Yeah, the sel.idx parameter should have contained named indices. Thanks for the catch 👍 The bug should be fixed with the latest commit. You can try out the development version and see if it works :)

adehman commented 3 years ago

Hi @jakob-wirbel ,

Thank you very much for your reactivity. model.interpretation.plot function with heatmap.type = 'fc' now works very well.