<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">I would say that in principle DatABEL::text2databel is the "natural" way to go from text-files to DatABEL-files<div><br></div><div>The problem is that 'regular' text input may be allele by allele, not genotype by genotype... (e.g. data are in format "A G", or "A/G", not "0" or "1" or "2"). </div><div><br></div><div>Y<br><div><br><div><div>On Nov 15, 2013, at 17:48 PM, L.C. Karssen <<a href="mailto:lennart@karssen.org">lennart@karssen.org</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Hi Maksim,<br><br>On 15-11-13 05:53, Maksim Struchalin wrote:<br><blockquote type="cite">An easy way to write a function for conversion a plink format file to a<br>GenABEL format file:<br><br>Use plink support of 'plug-in' functions<br></blockquote><br>Nice find. I didn't know that existed.<br><br><blockquote type="cite">(<a href="http://pngu.mgh.harvard.edu/~purcell/plink/rfunc.shtml">http://pngu.mgh.harvard.edu/~purcell/plink/rfunc.shtml</a>). This allows us<br>to write a simple R script (myscript.R) which is called by plink (plink<br>--file mydata --R myscript.R). plink reads the file mydata (which is in<br>plink format) and iteratively, SNP by SNP, trasfer all the data to a<br>script myscript.R. This script contains a function<br>Rplink(PHENO,GENO,CLUSTER,COVAR) which will take every SNP (GENO<br>variable) and store it in a *flv format through calling DatABEL functions.<br><br>The whole process of conversion will look like this:<br><br>1) User asks GenA convert plink file to GenA file<br>2) GenA looks weather the plink is installed. If it is not installed,<br>then GenA goes to a plink site and download/install it itself (use an R<br>function "download.file" from "utils" package)<br>3) GenA run a simple line: system('plink --file mydata --R myscript.R')<br>4) Rplink function (from myscript.R) gets every SNP and stote it in *flv<br>format. This function creates an flv file and then open and close it for<br>saving every single SNP.<br>5) Work is Done<br></blockquote><br>I'm not sure how portable it is to download and run plink. Also, the<br>plink page says: Currently, there is only support for R-plugins for<br>Linux-based and Mac OS PLINK distributions.<br><br><blockquote type="cite"><br>The only issue is how fast the converssion will run: how much time does<br>it take to open a filvector file, store one SNP and close it? I can not<br>find a DatABEL R function for adding SNP to a flv file. Is there a C<br>DatABEL function which can do it?<br></blockquote><br>Wouldn't it be easier/possible to use plink to export to text (.csv) and<br>then use filevector's txt2fvf binary (of course this could be done from<br>R using system())?<br><br>I'm also wondering if going per SNP is really necessary. If I understand<br>it correctly the R script (myscript.R) has to have a function called:<br>Rplink <- function(PHENO,GENO,CLUSTER,COVAR)<br>where GENO is the matrix of genotypes. So we could write that into a<br>DatABEL file at once. Of course you may want to do this per chromosome<br>to reduce memory consumption (not sure how plink/R would handle large<br>data sets).<br><br>I agree completely with Maarten that opening a filevector file for each<br>SNP will be an I/O killer.<br><br><br>Lennart.<br><br><blockquote type="cite"><br>best,<br>Maksim<br>_______________________________________________<br>genabel-devel mailing list<br><a href="mailto:genabel-devel@lists.r-forge.r-project.org">genabel-devel@lists.r-forge.r-project.org</a><br><a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/genabel-devel">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/genabel-devel</a><br></blockquote><br>--<span class="Apple-converted-space"> </span><br>-----------------------------------------------------------------<br>L.C. Karssen<br>Utrecht<br>The Netherlands<br><br><a href="mailto:lennart@karssen.org">lennart@karssen.org</a><br><a href="http://blog.karssen.org/">http://blog.karssen.org</a><br><br>Stuur mij aub geen Word of Powerpoint bestanden!<br>Zie<span class="Apple-converted-space"> </span><a href="http://www.gnu.org/philosophy/no-word-attachments.nl.html">http://www.gnu.org/philosophy/no-word-attachments.nl.html</a><br>------------------------------------------------------------------<br><br>_______________________________________________<br>genabel-devel mailing list<br><a href="mailto:genabel-devel@lists.r-forge.r-project.org">genabel-devel@lists.r-forge.r-project.org</a><br><a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/genabel-devel">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/genabel-devel</a></div></blockquote></div><br></div></div></body></html>