[GenABEL-dev] [Genabel-commits] r667 - in pkg/GenABEL: R man src/GAlib
Yurii Aulchenko
yurii.aulchenko at gmail.com
Sun Mar 6 20:57:41 CET 2011
Dear All,
In this commit I have addressed the feature request "option to have
header line missing in map-files used by convert.snp.ped"
https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1317&group_id=505&atid=2061
for reason why, see on forum
http://forum.genabel.org/viewtopic.php?f=6&t=14#p197
This appears to be very straightforward thing to do, but please have a look.
I did simple test using data in pkg/GenABEL/inst/exdata with and
without header line included in map.18, and all looked fine (resulting
.raw's diff = no diff).
You will see one more related commit on the commit-list -- I am sorry
about that, I was breaking the guideline not to commit before doing R
CMD check, and a couple of minor things (discrepancy
documentation/R-code) popped up there... Never again!
Yurii
On Sun, Mar 6, 2011 at 8:11 PM, <noreply at r-forge.wu-wien.ac.at> wrote:
> Author: yurii
> Date: 2011-03-06 20:11:17 +0100 (Sun, 06 Mar 2011)
> New Revision: 667
>
> Modified:
> pkg/GenABEL/R/convert.snp.ped.R
> pkg/GenABEL/man/convert.snp.ped.Rd
> pkg/GenABEL/src/GAlib/convert_snp_merlin.cpp
> pkg/GenABEL/src/GAlib/convert_snp_merlin_wslash.cpp
> Log:
> introduced an option 'mapHasHeaderLine' in convert.snp.ped, addressing feature request [#1317]
>
> Modified: pkg/GenABEL/R/convert.snp.ped.R
> ===================================================================
> --- pkg/GenABEL/R/convert.snp.ped.R 2011-03-04 18:44:15 UTC (rev 666)
> +++ pkg/GenABEL/R/convert.snp.ped.R 2011-03-06 19:11:17 UTC (rev 667)
> @@ -1,29 +1,40 @@
> -"convert.snp.ped" <- function(pedfile,mapfile,outfile,format="premakeped",traits=1,strand="u",bcast=10000000,wslash=F) {
> -
> +"convert.snp.ped" <-
> + function(pedfile,mapfile,outfile,format="premakeped",traits=1,
> + strand="u",bcast=10000000,wslash=FALSE,mapHasHeaderLine=TRUE)
> +{
> +
> alcodes <- alleleID.codes()
> -
> +
> poss <- c("u","+","-","file")
> intstrand <- which(poss == strand)-1
> if (length(intstrand)!=1) {cat("strand argument must be one of",poss,"\n");stop();}
> -
> +
> # strand == 0 -> unknown ('u')
> # strand == 1 -> plus ('+')
> # strand == 2 -> minus ('-')
> # extendedmap -> five columns (chr,name,pos,strand,coding) expected in map-file
> # passed through intstrand <- 3 !
> -
> +
> posf <- c("premakeped","mach")
> intfmt <- which(posf == format)-1
> if (length(intfmt)!=1) {cat("format argument must be one of",posf,"\n");stop();}
> -
> +
> # intfmt = 0 -> premakeped, merlin
> # else -> mach
> -
> +
> if (wslash) {
> - .C("convert_snp_merlin_wslash",as.character(pedfile),as.character(mapfile),as.character(outfile),as.integer(intstrand),as.integer(bcast),as.character(alcodes),as.integer(length(alcodes)),as.integer(intfmt),as.integer(traits),PACKAGE="GenABEL")
> + .C("convert_snp_merlin_wslash",as.character(pedfile),as.character(mapfile),
> + as.character(outfile),as.integer(intstrand),as.integer(bcast),
> + as.character(alcodes),as.integer(length(alcodes)),as.integer(intfmt),
> + as.integer(traits),as.integer(mapHasHeaderLine),
> + PACKAGE="GenABEL")
> } else {
> - .C("convert_snp_merlin",as.character(pedfile),as.character(mapfile),as.character(outfile),as.integer(intstrand),as.integer(bcast),as.character(alcodes),as.integer(length(alcodes)),as.integer(intfmt),as.integer(traits),PACKAGE="GenABEL")
> + .C("convert_snp_merlin",as.character(pedfile),as.character(mapfile),
> + as.character(outfile),as.integer(intstrand),as.integer(bcast),
> + as.character(alcodes),as.integer(length(alcodes)),as.integer(intfmt),
> + as.integer(traits),as.integer(mapHasHeaderLine),
> + PACKAGE="GenABEL")
> }
> - return(invisible(0))
> + return(invisible(0))
> }
>
>
> Modified: pkg/GenABEL/man/convert.snp.ped.Rd
> ===================================================================
> --- pkg/GenABEL/man/convert.snp.ped.Rd 2011-03-04 18:44:15 UTC (rev 666)
> +++ pkg/GenABEL/man/convert.snp.ped.Rd 2011-03-06 19:11:17 UTC (rev 667)
> @@ -6,14 +6,15 @@
> }
> \usage{
> convert.snp.ped(pedfile, mapfile, outfile, format = "premakeped", traits = 1,
> - strand = "u", bcast = 10000000, wslash=F)
> + strand = "u", bcast = 10000000, wslash=FALSE, mapHasHeaderLine=TRUE)
> }
> \arguments{
> \item{pedfile}{
> - Pre-makeped linkage genotypic data file name
> + Pre-makeped linkage genotypic data file name (no header line)
> }
> \item{mapfile}{
> - Name of the map file
> + Name of the map file (note that by default header line should be included,
> + see 'mapHasHeaderLine' to modify that)
> }
> \item{outfile}{
> Output data file
> @@ -41,6 +42,9 @@
> wslash=T it is assumed that genotypes are coded with single characters,
> separated with slash (no spaces), e.g. "A/G", and not "A/ G" or "A / G".
> }
> + \item{mapHasHeaderLine}{
> + Whether map-file has a header line
> + }
> }
> \details{
> Pedfile must be standard pre-makeped/Merlin linkage file, or a Mach file.
> @@ -89,8 +93,9 @@
>
> Accepted strand coding: +, -, u (unknown)
>
> - Please note that the header line (e.g. "chrom name position") SHOULD
> - be present in your file!
> + Please note that by default the header line (e.g. "chrom name position") SHOULD
> + be present in your file, though you can use 'mapHasHeaderLine' argument to modify
> + this behavior
>
> }
> \value{
>
> Modified: pkg/GenABEL/src/GAlib/convert_snp_merlin.cpp
> ===================================================================
> --- pkg/GenABEL/src/GAlib/convert_snp_merlin.cpp 2011-03-04 18:44:15 UTC (rev 666)
> +++ pkg/GenABEL/src/GAlib/convert_snp_merlin.cpp 2011-03-06 19:11:17 UTC (rev 667)
> @@ -41,7 +41,9 @@
> **/
>
> extern "C" {
> - void convert_snp_merlin (char** pedfilename, char** mapfilename, char** outfilename, int* Strandid, int* bcast, char **allele_codes, int* Ncodes, int *Fmt, int *Tra) {
> + void convert_snp_merlin (char** pedfilename, char** mapfilename, char** outfilename,
> + int* Strandid, int* bcast, char **allele_codes, int* Ncodes,
> + int *Fmt, int *Tra, int *MapHasHeaderLine) {
>
> int verbose = *bcast ? 1 : 0;
>
> @@ -49,6 +51,7 @@
> int strandid = *Strandid;
> int format = *Fmt;
> int traits = *Tra;
> + int mapHasHeaderLine = *MapHasHeaderLine;
>
> long int linecount=0;
> string data;
> @@ -83,7 +86,8 @@
> }
>
> int mapline=0;
> - getline(mapfile,data);
> +// read and ignore header line
> + if (mapHasHeaderLine) getline(mapfile,data);
> if (strandid==3) {
> while (getline(mapfile,data)) {
> istringstream datas (data);
>
> Modified: pkg/GenABEL/src/GAlib/convert_snp_merlin_wslash.cpp
> ===================================================================
> --- pkg/GenABEL/src/GAlib/convert_snp_merlin_wslash.cpp 2011-03-04 18:44:15 UTC (rev 666)
> +++ pkg/GenABEL/src/GAlib/convert_snp_merlin_wslash.cpp 2011-03-06 19:11:17 UTC (rev 667)
> @@ -40,7 +40,9 @@
> **/
>
> extern "C" {
> - void convert_snp_merlin_wslash (char** pedfilename, char** mapfilename, char** outfilename, int* Strandid, int* bcast, char **allele_codes, int* Ncodes, int *Fmt, int *Tra) {
> + void convert_snp_merlin_wslash (char** pedfilename, char** mapfilename,
> + char** outfilename, int* Strandid, int* bcast, char **allele_codes,
> + int* Ncodes, int *Fmt, int *Tra, int *MapHasHeaderLine) {
>
> int verbose = *bcast ? 1 : 0;
>
> @@ -48,6 +50,7 @@
> int strandid = *Strandid;
> int format = *Fmt;
> int traits = *Tra;
> + int mapHasHeaderLine = *MapHasHeaderLine;
>
> long int linecount=0;
> string data;
> @@ -82,7 +85,8 @@
> }
>
> int mapline=0;
> - getline(mapfile,data);
> +// read and ignore header line
> + if (mapHasHeaderLine) getline(mapfile,data);
> if (strandid==3) {
> while (getline(mapfile,data)) {
> istringstream datas (data);
>
> _______________________________________________
> Genabel-commits mailing list
> Genabel-commits at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/genabel-commits
>
More information about the genabel-devel
mailing list