dcp
New Member
Posts: 1
|
Post by dcp on Jun 1, 2015 1:09:41 GMT
Hi,
Im new to R and having difficulties reading in the code.
How do I import the grm into R once I have ran the following script? When I type ReadGRMBin it will sow the code, do I have to envoke the function someway?
prefix <- "C:/sta_meta/dee_trial/gcta64_results/grm_hdsta50" ReadGRMBin=function(prefix, AllN=F, size=4){ sum_i=function(i){ return(sum(1:i)) } BinFileName=paste(prefix,".grm.bin",sep="") NFileName=paste(prefix,".grm.N.bin",sep="") IDFileName=paste(prefix,".grm.id",sep="") id = read.table(IDFileName) n=dim(id)[1] BinFile=file(meta, "rb"); grm=readBin(BinFile, n=n*(n+1)/2, what=numeric(0), size=size) NFile=file(meta, "rb"); if(AllN==T){ N=readBin(NFile, n=n*(n+1)/2, what=numeric(0), size=size) } else N=readBin(NFile, n=1, what=numeric(0), size=size) i=sapply(1:n, sum_i) return(list(diag=grm, off=grm[-i], id=id, N=N)) }
Many thanks
|
|
|
Post by Zhihong Zhu on Jun 2, 2015 1:08:46 GMT
Hi there,
Since the parameter "prefix" and the function "ReadGRMBin" are available now, you could simply call the function to get GRM elements,
e.g. grm = ReadGRMBin(prefix) diag = grm$diag off = grm$off id = grm$id n = grm$n
Cheers, Zhihong
|
|