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

I created the files similar to en example given in 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"


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





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.


ldheatmap • 5.2k views
ADD COMMENTlink modified 3.4 years ago by ATCG300 • written 6.7 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 6.4 years ago by Istvan Albert ♦♦ 86k • written 6.4 years ago by aiguoss09020
gravatar for Devon Ryan
6.7 years ago by
Devon Ryan98k
Freiburg, Germany
Devon Ryan98k 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 6.7 years ago by Devon Ryan98k
gravatar for jiaobingke
4.4 years ago by
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 4.4 years ago by jiaobingke20

Glad it works :)

ADD REPLYlink written 4.4 years ago by Devon Ryan98k
gravatar for ATCG
3.4 years ago by
ATCG300 wrote:

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

ADD COMMENTlink written 3.4 years ago by ATCG300
Please log in to add an answer.


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