Question: How to solve the problem when I get error message "column 1 is not a genotype object" in LDheatmap in R?
1
gravatar for vyoouh
4.8 years ago by
vyoouh20
France
vyoouh20 wrote:

I created the files similar to en example given in http://cran.r-project.org/web/packages/LDheatmap/vignettes/LDheatmap.pdf. Which are CEUDist (only one column of distance) and CEUSNP (genotypic data, with the markers name). However, I obtained the error saying  "column 1 is not a genotype object"

CEUSNP

snp1    snp2    snp3    snp4    snp5    snp6
G/G    A/A    C/C    G/G    G/G    G/G
A/A    G/G    C/C    G/G    A/A    G/G
G/G    G/G    C/C    G/G    G/G    G/G
G/G    G/G    C/C    G/G    A/A    G/G
G/G    G/G    C/C    T/T    A/A    G/G
G/G    G/G    A/A    T/T    G/G    G/G
G/G    G/G    A/A    G/G    G/G    G/G
A/A    G/G    C/C    T/T    A/A    G/G
A/A    G/G    C/C    G/G    G/G    G/G
A/A    G/G    <NA>    G/G    A/A    G/G
A/A    G/G    A/A    G/G    A/A    G/G
G/G    G/G    A/A    G/G    G/G    G/G
G/G    G/G    C/C    G/G    A/A    G/G

 

and 

CEUDist 

123456
123524
123457
123525
123458
123526

Could you tell me what I did wrong in this case?

Also, can I use CC instead of C/C and NA instead of <NA> in the genotypic file?

It will be great if any of you can share an example files with me.

 

Thank you in advance.

Jane

ldheatmap • 3.8k views
ADD COMMENTlink modified 18 months ago by DataFanatic130 • written 4.8 years ago by vyoouh20

Thank you for your answer! I have met the same question, but I dont know how to use the fuction genotype, could you give the examples? I appreciate. Deletion should be reserved to errors or inappropriate content.

ADD REPLYlink modified 4.5 years ago by Istvan Albert ♦♦ 80k • written 4.5 years ago by aiguoss09020
1
gravatar for Devon Ryan
4.8 years ago by
Devon Ryan89k
Freiburg, Germany
Devon Ryan89k wrote:

The vignette for that package is terrible. You need to load the genetics package and then use genotype() when creating the data.frame. In short, you need two columns for each individual, one column per allele. That genotype function will then return a properly formatted genotype object. You'll do that for each SNP and save the results in a data.frame. They really should have given an example in the vignette.

ADD COMMENTlink written 4.8 years ago by Devon Ryan89k
1
gravatar for jiaobingke
2.5 years ago by
jiaobingke20
jiaobingke20 wrote:

I came across the same question as you do. I convert the data.frame of my own data into a genotype object using the Devon Ryan's suggestion and It works! There is a as.genotype() function in genetics package.I use this function to convert the normal data.frame to a genotype object. The example is

num<-ncol(SNPdata)        # SNPdata is a data.frame which looks like the CEUSNP above.
colnames(SNPdata)<-map$V2 # Name the SNPdata columns with the 2nd column of map file(produced by vcftools).

class(SNPdata[,1]) # You will get "factor".

for(i in 1:num){
 SNPdata[,i]<-as.genotype(SNPdata[,i]) # convert the columns of the original data frame into  genotype objects
}

class(SNPdata[,1])  #Here you can see the class becomes "genotype factor".Then you can put the SNPdata into LDheatmap().

Thank you and Devon Ryan!

ADD COMMENTlink written 2.5 years ago by jiaobingke20

Glad it works :)

ADD REPLYlink written 2.5 years ago by Devon Ryan89k
0
gravatar for  DataFanatic
18 months ago by
DataFanatic130
DataFanatic130 wrote:

how can one create a data.frame which looks like the CEUSNP from a vcf file?.

ADD COMMENTlink written 18 months ago by DataFanatic130
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 715 users visited in the last hour