gscramble2newhybrids {gscramble}R Documentation

Convert 'gscramble' output to newhybrids format

Description

This function turns character-based alleles into integers and writes the necessary headers, etc. It preferentially uses the "id" column if it exists in M$ret_ids. Otherwise it uses the indiv column for the sample names.

Usage

gscramble2newhybrids(
  M,
  M_meta,
  z = NULL,
  s = NULL,
  retain = NULL,
  outfile = tempfile()
)

Arguments

M

the output from segments2markers() from 'gscramble'. This could have an added id column on it, which will then be used for the sample names.

M_meta

the Marker meta data file.

z

A vector of length two. The values are regular expressions that the sample names that you want to have -z 0 or -z 1 should match. For example c("SH", "CCT") means any sample matching "SH" would get z0 and any sample matchine "CCT" would get z1.

s

a single regular expressions that matches individuals that should be given the -s option. For example "SH|CCT"

retain

a vector of loci to retain.

outfile

path to the file to write the newhybrids data set to. For CRAN compliance, this is, by default, a temp file. But you can change it to be anything valid.

Details

It allows you to set the -s and -z through some regular expression mapping.

This function relies a lot on some tidyverse functions for pivoting, etc. As such, it is not intended for data sets with tens of thousands of markers. You oughtn't be using NewHybrids with so many markers, anyway!

Value

A list with three components:

Examples

# get output from segments2markers():
example("segments2markers")
# copy that result to a new variable
M <- s2m_result

# then run it
gscramble2newhybrids(M, M_meta)

[Package gscramble version 1.0.1 Index]