Ldheatmap In R
2
2
Entering edit mode
10.1 years ago
lkmklsmn ▴ 970

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 • 7.9k views
ADD COMMENT
1
Entering edit mode
10.1 years ago
lkmklsmn ▴ 970

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...

ADD COMMENT
1
Entering edit mode
10.1 years ago

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.

ADD COMMENT

Login before adding your answer.

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