Skip to contents

This function serves for step 1 of chapter 1.1 of the "Using VCFtoGWAS package" markdown series.
Based on the GWAS matrix of the parents (assuming the matrix was built based on diploid parents), a matrix is built for the offspring of the parents.

Usage

Build_offspring_GWAS_matrix(parent_GWAS_mat,
                            offspring_strains,
                            dir_results = getwd(),
                            results_name = name_by_time(),
                            do_save = TRUE,
                            seed = 10,
                            save_hashed_matrix = FALSE)

Arguments

parent_GWAS_mat

A GWAS matrix (composed of 0,1,2,NA) where the rownames are the parent strains

offspring_strains

An array of the names of the offspring, must be composed of the parent names

dir_results

The directory in which a folder will be created and results will be saved. Make sure it exists!!!

results_name

The name of the folder in which the results will be saved within dir_results (default is a time stamp, see create_directory function)

do_save

Do you wish to save the results? (will be saved as RDS files) (Default is TRUE)

seed

The function includes random sampling. A seed can be set and changed.

save_hashed_matrix

Do you wish to also save the the "mid-product" of the function (the hashed matrix). Default is FALSE

Details

Hashing the table:
If parent1 is "BNI" and parent2 is "BKE" than the offspring name is "BNIBKE".
A hashed value for "BNIBKE" (denoted BNIBKE^[i,j]) is given by:
BNIBKE^[i,j] = (BNI[i,j] + BKE[i,j]) + (BNI[i,j] * BKE[i,j])

Un-hashing the table:

  • (0 + 0) + (0 * 0) = 0 ==> BNIBKE[i,j] = 0

  • (0 + 1) + (0 * 1) = 1 ==> BNIBKE[i,j] = 0 or 1

  • (0 + 2) + (0 * 2) = 2 ==> BNIBKE[i,j] = 1

  • (1 + 1) + (1 * 1) = 3 ==> BNIBKE[i,j] = 0 or 1 or 2

  • (1 + 2) + (1 * 2) = 5 ==> BNIBKE[i,j] = 1 or 2

  • (2 + 2) + (2 * 2) = 8 ==> BNIBKE[i,j] = 2

  • NA in any of them results in NA

Value

The returned object is a list of length 3 or 1:

offspring_GWAS_mat

The created GWAS matrix of the offspring (always returned)

mapping_info_offspring

The mapping info linking between the SNPs and their location (after the creation of the new matrix, some SNPs are removed)

results_directory

If the results are saved, this is the directory where they were saved

Author

Tomer Antman