kbroman / qtl

R/qtl: A QTL mapping environment
https://rqtl.org
GNU General Public License v3.0
77 stars 45 forks source link

Additive effect heatmap #54

Open jcberny opened 7 years ago

jcberny commented 7 years ago

I would like to plot a heatmap of the additive effects. Similar to the output in genstat (attached). It's useful to see differences in effects between environments and traits Would you have any suggestion? I think it would be a good addition to the chart package.

additiveheatmap

DannyArends commented 7 years ago

The mqmplot.heatmap function does more or less what you want. if you use the mqmscan function with model="additive" and then plot the results using the mqmplot.heatmap function you get an image very similar to what you want. it also allows you to create a directed heatmap.

You might want to adjust the code of the function to be more generic, or to use different colors/breaks for significance.

Gr, Danny

jcberny commented 7 years ago

Hi Danny,

Thanks. But it's heatmapping the LOD score or not the additive effect?

With regards,

Jorge

DannyArends commented 7 years ago

Hey Jorge,

It is indeed showing the LOD scores for the additive effects (use model="dominance" for LOD scores of the dominance component)

I don't really understand how you want to make that into a generic function, since the scale and units of the additive effect of each phenotype can be quite different. e.g. imagine mapping phenotypes on horses, a 1 cm difference in leg length on a marker can be insignificant, but a 1 cm change in ear length can be a huge difference. Both of these differences are equal and would show with the same color on the heat map, while in the one case there would be a significant different, while in the other case there would not be.

The other issue is with units, e.g. a phenotype measured in meters the other one in cubic meters, how do we plot both of these in an equal way.

If you know your phenotypes have similar units and scale you can make this function of course, but it would only be useful in a number of circumstances. and even then the same difference in phenotype (think 1cm) could be significant in one situation, while not being significant in the other (based on the variance in a phenotype)

I think just plotting the LOD scores is much more informative, see the example attached where the phenotypes have a huge range difference

    library(qtl)
    data(multitrait)
    multitrait <- fill.geno(multitrait) # impute missing genotype data
    result <- mqmscanall(multitrait, logtransform=TRUE, model="additive")
    res <- NULL
    for(x in 1:24){
      res <- cbind(res, effectscan(sim.geno(multitrait), pheno.col=x)[,3])
    }
    op <- par(mfrow = c(2,1),mar=c(1,10,1,1))
    mqmplot.heatmap(multitrait,result)
    image(res, yaxt="n")
    axis(2, at=1:24/24, colnames(pull.pheno(multitrait)), las=2)

image

here we see 24 phenotypes, from the LOD scores (top) it is clear some phenotypes have a QTL on chromosome 5, some have a QTL on chromosome 1, from the the additive effect plot (bottom) it is not clear at all since there is one phenotype dominating the plot.

Anyway, feel free to adjust the code used to produce the output you want