This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Ldheatmap In R

Hi,
I am trying to build a LD heatmap in R. To do this I installed the 'genetics' and 'LDheatmap' packages.
I am not an expert in R, but I am also not completely new to it. Why does this not work?
x<-c(2,2,2,2,2,2,2)
is.gene(genotype(as.genotype.allele.count(as.numeric(x))))
[1] FALSE
??? Why cant I create a genotype object this way?

r ld heatmap

2 answers

I managed to figure it out myself. I guess apply does not work for genotype objects, so I used lapply followed by do.call instead. Not sure if this was due to my lack of R skills or if there is actually an error in the 'genetics' package. Hope this helps somebody...

If you're working with a matrix you can implement heatmap() or heatmap2()

 library(gplots)
 heatmap2(matrix)

That's pretty much it. ggplots2 also has a correlation matrix function

library(ggplot2)
library(corrplot)
corrplot(matrix)

There's lots of options in R for heatmaps/correlation matrices. The documentation is very useful too.

Log in to answer this question.