Question: SOLVED: how to change SnpMatrix in to numeric
0
gravatar for zwang10
19 months ago by
zwang100
United States
zwang100 wrote:

I use read.plink from package snpStats. I use following to read bed file, and I want to get the 0,1,2 matrix.

GENOTYPE=read.plink("chr22_1",na.strings = "NA")

Then, from the manuals, I know there is a "genotypes" value of GNEOTYPE, which is an object of class "SnpMatrix". And I got this

> genotype$genotypes
A SnpMatrix with  1497 rows and  6 columns
Row names:  ALS5085249 ... ALS5227466 
Col names:  rs62224609 ... rs62224618

Can someone tell me how to change it into 0,1,2 matrix?

My work, I tried to use

    coerce(genotype$genotypes,to="numeric")

And I got something like this, which is not numeric.

           rs62224609 rs80167676 rs3013006 rs9604721 rs117246541 rs62224618
ALS5085249 "B/B"      "B/B"      "B/B"     "B/B"     "B/B"       "B/B"     
ALS5085250 "B/B"      "B/B"      "A/B"     "B/B"     "B/B"       "B/B"     
ALS5085251 "A/B"      "A/B"      "B/B"     "B/B"     "A/B"       "A/B"     
ALS5085252 "B/B"      "B/B"      "A/B"     "B/B"     "B/B"       "B/B"     
ALS5085253 "B/B"      "B/B"      "B/B"     "B/B"     "B/B"       "B/B"     
ALS5085254 "A/B"      "B/B"      "A/B"     "B/B"     "B/B"       "A/B"     
Warning message:
In coerce(genotype$genotypes, to = "numeric") :
  direct use of coerce() is deprecated:  use as(from, class(to)) instead
snpmatrix R • 895 views
ADD COMMENTlink modified 9 days ago by catherinem.ross0 • written 19 months ago by zwang100

If this is solved, could you post your solution please

ADD REPLYlink written 18 months ago by russhh2.9k
0
gravatar for catherinem.ross
9 days ago by
catherinem.ross0 wrote:

Use the function indicated in the warning message:

as(genotype$genotypes, to="numeric")

the coerce function is deprecated.

ADD COMMENTlink modified 9 days ago • written 9 days ago by catherinem.ross0
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: 935 users visited in the last hour