[R-br] dim(X)

Éder Comunello comunello.eder em gmail.com
Quinta Novembro 21 13:24:08 BRST 2013


Giselle,

Faltou usar a primeira coluna como row.names....

Já atualizei o código que segue abaixo:

### <BEGIN>
###
browseURL('
http://cran.r-project.org/web/packages/rrBLUP/vignettes/GS_tutorial.pdf')
###
setwd("C:/LAB/Tmp"); getwd()
dURL   <- "
https://www.crops.org/publications/tpg/supplements/5/tpg12-06-0006-dataset-s2.gz
"
gzFile <- strsplit(dURL, "/")[[1]][8]; gzFile

### fazendo o download
download.file(dURL, gzFile, mode='wb')
### downloaded 4.3 Mb

### uma vez baixados, os arquivos comprimidos com bzip2, xvz, ou gzip podem
### ser lidos diretamente com read.table()
GBS <- read.table(gzFile, sep=',', header=T, stringsAsFactors=F,
row.names=1)
dim(GBS)
### [1] 41371   257

parse.GBS <- function(x) {
   unique.x <- unique(x)
   alleles <- setdiff(unique.x,union("H","N"))
   y <- rep(0,length(x))
   y[which(x==alleles[1])] <- -1
   y[which(x==alleles[2])] <- 1
   y[which(x=="N")] <- NA
   return(y)
}

X <- apply(GBS[,-c(1:3)],1,parse.GBS)
dim(X)
### [1]   254 41371

frac.missing <- apply(X,2,function(z){length(which(is.na(z)))/length(z)})
length(which(frac.missing<0.5))
### [1] 16030

hist(frac.missing)
### OK!!!

### <END>


Éder Comunello <c <comunello.eder em gmail.com>omunello.eder em gmail.com>
Dourados, MS - [22 16.5'S, 54 49'W]
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://listas.inf.ufpr.br/pipermail/r-br/attachments/20131121/4e5526f9/attachment.html>


Mais detalhes sobre a lista de discussão R-br