I have an error while running the script to separate genotype, phenotype, and map. I didn't get the point as the missing datas are introduced as NAs. i have tried to run the following script to perform segregation script but i have an error while f<-which(seg[,3]>10)
The code and the warning is as below. can you please explain me and help me out with the error
I have also attached the screenshot and the script for your reference......
geno0<-read.csv('bp_pont.csv')
> geno0<-geno0[-c(3,4),]
> pheno<-geno0[-c(1,2),1:5]
> pheno[pheno=='-']<-NA
> pheno<-data.frame(apply(pheno,2,as.numeric))
> rownames(pheno)<-geno0$Markername[-c(1,2)]
>
> x<-data.frame(t(geno0[1:2,-c(1:6)]))
> map<-data.frame(marker=rownames(x),chr=as.numeric(x[,1]),pos=as.numeric(x[,2]))
Warning messages:
1: In data.frame(marker = rownames(x), chr = as.numeric(x[, 1]), pos = as.numeric(x[, :
NAs introduced by coercion
2: In data.frame(marker = rownames(x), chr = as.numeric(x[, 1]), pos = as.numeric(x[, :
NAs introduced by coercion
> rownames(map)<-map$marker
>
> geno<-geno0[-c(1:2),-c(1:6)]
> rownames(geno)<-rownames(pheno)
> geno[geno=='-']<-NA
> seg<-t(apply(geno,2,function(x){
+ w<-c(0,0,0)
+ names(w)<-c('A','B','H')
+ y<-table(x)
+ w[names(y)]<-y
+ return(w)
+ }))
>
>
> f<-which(seg[,3]>10)
Error in which(seg[, 3] > 10) :
'list' object cannot be coerced to type 'double'
> geno<-geno[,-f]
Error in `[.data.frame`(geno, , -f) : object 'f' not found
> map<-map[-f,]
Error in `[.data.frame`(map, -f, ) : object 'f' not found
thanks and regards
Rami