[GenABEL-dev] Float to double conversion in filevector/DatABEL files
L.C. Karssen
lennart at karssen.org
Mon Feb 11 23:40:57 CET 2013
Dear list,
As I was trying to improve the concordance between the results of
palinear and pacoxph with their R counterparts I ran into the following:
First I set the number of significant digits in the ProbABEL output a
bit higher. I also changed the use of floats for SNP data to doubles.
With that the ratio of beta_PA/beta_R equals 1. At least that's what I
first saw. I also noticed that now the outputs when using dose and prob
files were identical!
However, it turns out that this is only true when using plain text
files (non-filevector) for input. Before my changes there was no diff
between regular and filevector output. Now there is...
The relevant section for text files in gendata.cpp is in lines 166-175
approximately:
double dosage = strtod(tmpstr.c_str(), (char **) NULL);
G.put(dosage, k, j);
Here the G matrix (a double in my case) with the double dosage that
results from strtod().
For filevector files things become complicated. In gendata.cpp lines
20-47 the following line is used to read the SNP data:
float tmpdata[DAG->getNumObservations()];
DAG->readVariableAs((unsigned long int) var, tmpdata);
I tried to change the float into a double, but when inspecting the
values in tmpdata[] I notice that there are rounding errors typical of a
float to double cast (e.g. 1.66 in the dose.fv file becomes 1.65999998).
I tried to dig into the fvlib a bit and it seems that readVariableAs()
performs a cast based on the data type stored in the fv file. From the
DatABEL manual I gathered that you can specify a data type for fv files.
Does someone know how I can read the header of an fv file to check the
data type used in a give fv file?
It seems to me that if the data type is indeed stored in the header (and
assuming we don't want to convert all our fv files) my problem is
difficult to fix. Since the fv data is not stored as text we can't use a
strtod()-like function to get the correct values as doubles.
Anyone has any ideas/suggestions?
Thanks,
Lennart.
--
-----------------------------------------------------------------
L.C. Karssen
Utrecht
The Netherlands
lennart at karssen.org
http://blog.karssen.org
Stuur mij aub geen Word of Powerpoint bestanden!
Zie http://www.gnu.org/philosophy/no-word-attachments.nl.html
------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 230 bytes
Desc: OpenPGP digital signature
URL: <http://lists.r-forge.r-project.org/pipermail/genabel-devel/attachments/20130211/4a222103/attachment.sig>
More information about the genabel-devel
mailing list