matrix type in R conversion

54 Views Asked by At

I have a matrix that looks like this : enter image description here

It seems that it is as I understand a numeric matrix . (it contains only values of 0,1,and 2) the sparse matrix is created with the package sim1000G :

get_genotype=function(vcf_path){
  vcf = readVCF( vcf_path ,min_maf = NA, max_maf = NA,maxNumberOfVariants = 10000)
  startSimulation(vcf, totalNumberOfIndividuals = 3010)
  ids = generateUnrelatedIndividuals(3000)
  genotype = retrieveGenotypes(ids)
  return(genotype)
  
}


genotype_HLA_DRB5=get_genotype("HLA_DRB5.vcf")

I have another matrix that looks like this enter image description here

dim(genotype_sorcs)
[1] 3000 3984

what I would like to do is convert the second matrix so it would not be Large matrix but will look like the first one meaning : num[1:3000,1:3984]

I tried this :

genotype_sorcs=as.numeric(genotype_sorcs)

But it didn't produce the desired output .Would be happy for your help

1

There are 1 best solutions below

1
liza read On
mode(genotype_sorcs)="numeric"

transforms it