Entering edit mode
8.4 years ago
zwang10
▴
30
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
If this is solved, could you post your solution please