Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
^LICENSE\.md$
^revdep$
^cran-comments\.md$
^.github$
21 changes: 13 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
Package: BIGr
Title: Breeding Insight Genomics Functions for Polypoid and Diploid Species
Title: Breeding Insight Genomics Functions for Polypoid and Diploid
Species
Version: 0.5.0
Author: Alexander M. Sandercock, Cristiane H. Taniguti, Josue
Chinchilla-Vargas, Shufen Chen, Manoj Sapkota, Meng Lin, Dongyan Zhao,
and Breeding Insight Team
Maintainer: Alexander M. Sandercock <[email protected]>
Description: Functions developed within Breeding Insight to analyze diploid and polyploid
breeding and genetic data. 'BIGr' provides the ability to filter VCF files, extract SNPs from the DArT MADC file,
and manipulate genotype data for both diploid and polyploid species. It also serves
as the core dependency for the 'BIGapp' Shiny app, which provides a user-friendly interface for performing routine genotype analysis tasks
such as dosage calling, filtering, PCA, GWAS, and Genomic Prediction.
Description: Functions developed within Breeding Insight to analyze
diploid and polyploid breeding and genetic data. 'BIGr' provides the
ability to filter VCF files, extract SNPs from the DArT MADC file, and
manipulate genotype data for both diploid and polyploid species. It
also serves as the core dependency for the 'BIGapp' Shiny app, which
provides a user-friendly interface for performing routine genotype
analysis tasks such as dosage calling, filtering, PCA, GWAS, and
Genomic Prediction.
License: Apache License (>= 2)
URL: https://github.com/Breeding-Insight/BIGr
BugReports: https://github.com/Breeding-Insight/BIGr/issues
License: Apache License (>= 2)
Depends:
R (>= 4.4.0)
Imports:
Expand All @@ -24,6 +28,7 @@ Imports:
methods,
parallel,
pwalign,
quadprog,
Rdpack (>= 0.7),
readr (>= 2.1.5),
reshape2 (>= 1.4.4),
Expand All @@ -33,7 +38,7 @@ Imports:
utils,
vcfR (>= 1.15.0)
Suggests:
testthat (>= 3.0.0)
testthat (>= 3.0.0)
RdMacros:
Rdpack
Encoding: UTF-8
Expand Down
10 changes: 4 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
# Generated by roxygen2: do not edit by hand

export(add_ref_alt)
export(allele_freq_poly)
export(calculate_Het)
export(calculate_MAF)
export(capture_diversity.Gmat)
export(check_ped)
export(compare)
export(create_VCF_body)
export(dosage2vcf)
export(dosage_ratios)
export(filterVCF)
export(flip_dosage)
export(get_OffTargets)
export(get_countsMADC)
export(get_ref_alt_hap_seq)
export(imputation_concordance)
export(loop_though_dartag_report)
export(madc2vcf)
export(merge_MADCs)
export(merge_counts)
export(solve_composition_poly)
export(updog2vcf)
import(doParallel)
import(dplyr)
import(foreach)
import(janitor)
import(parallel)
import(quadprog)
import(tibble)
import(tidyr)
import(vcfR)
Expand All @@ -37,6 +34,7 @@ importFrom(pwalign,pairwiseAlignment)
importFrom(readr,read_csv)
importFrom(reshape2,dcast)
importFrom(reshape2,melt)
importFrom(stats,cor)
importFrom(stats,lm)
importFrom(stats,qt)
importFrom(stats,sd)
Expand Down
82 changes: 70 additions & 12 deletions R/breedtools_functions.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
#' Computes allele frequencies for specified populations given SNP array data
#'
#' @param geno matrix of genotypes coded as the dosage of allele B {0, 1, 2, ..., ploidy}
#' @param geno matrix of genotypes coded as the dosage of allele B \code{{0, 1, 2, ..., ploidy}}
#' with individuals in rows (named) and SNPs in columns (named)
#' @param populations list of named populations. Each population has a vector of IDs
#' that belong to the population. Allele frequencies will be derived from all animals
#' @param ploidy integer indicating the ploidy level (default is 2 for diploid)
#' @return data.frame consisting of allele_frequencies for populations (columns) for
#' each SNP (rows)
#' @references Funkhouser SA, Bates RO, Ernst CW, Newcom D, Steibel JP. Estimation of genome-wide and locus-specific
#' breed composition in pigs. Transl Anim Sci. 2017 Feb 1;1(1):36-44.
#'
#' @examples
#' # Example inputs
#' geno_matrix <- matrix(
#' c(4, 1, 4, 0, # S1
#' 2, 2, 1, 3, # S2
#' 0, 4, 0, 4, # S3
#' 3, 3, 2, 2, # S4
#' 1, 4, 2, 3),# S5
#' nrow = 4, ncol = 5, byrow = FALSE, # individuals=rows, SNPs=cols
#' dimnames = list(paste0("Ind", 1:4), paste0("S", 1:5))
#' )
#'
#'pop_list <- list(
#' PopA = c("Ind1", "Ind2"),
#' PopB = c("Ind3", "Ind4")
#' )
#'
#' allele_freqs <- allele_freq_poly(geno = geno_matrix, populations = pop_list, ploidy = 4)
#' print(allele_freqs)
#'
#' @export
allele_freq_poly <- function(geno, populations, ploidy = 2) {

Expand Down Expand Up @@ -37,16 +60,20 @@ allele_freq_poly <- function(geno, populations, ploidy = 2) {
}


# Performs whole genome breed composition prediction.
#
# @param Y numeric vector of genotypes (with names as SNPs) from a single animal.
# coded as dosage of allele B {0, 1, 2}
# @param X numeric matrix of allele frequencies from reference animals
# @param p numeric indicating number of breeds represented in X
# @param names character names of breeds
# @return data.frame of breed composition estimates
# @import quadprog
# @export
#' Performs whole genome breed composition prediction.
#'
#' @param Y numeric vector of genotypes (with names as SNPs) from a single animal.
#' coded as dosage of allele B \code{{0, 1, 2, ..., ploidy}}
#' @param X numeric matrix of allele frequencies from reference animals
#' @param p numeric indicating number of breeds represented in X
#' @param names character names of breeds
#' @return data.frame of breed composition estimates
#' @import quadprog
#' @importFrom stats cor
#' @references Funkhouser SA, Bates RO, Ernst CW, Newcom D, Steibel JP. Estimation of genome-wide and locus-specific
#' breed composition in pigs. Transl Anim Sci. 2017 Feb 1;1(1):36-44.
#'
#' @noRd
QPsolve <- function(Y, X) {

# Remove NAs from Y and remove corresponding
Expand Down Expand Up @@ -90,7 +117,7 @@ QPsolve <- function(Y, X) {
#' batch of animals.
#'
#' @param Y numeric matrix of genotypes (columns) from all animals (rows) in population
#' coded as dosage of allele B {0, 1, ..., ploidy}
#' coded as dosage of allele B \code{{0, 1, 2, ..., ploidy}}
#' @param X numeric matrix of allele frequencies (rows) from each reference panel (columns). Frequencies are
#' relative to allele B.
#' @param ped data.frame giving pedigree information. Must be formatted "ID", "Sire", "Dam"
Expand All @@ -107,6 +134,37 @@ QPsolve <- function(Y, X) {
#' @return A data.frame or list of data.frames (if groups is !NULL) with breed/ancestry composition
#' results
#' @import quadprog
#' @references Funkhouser SA, Bates RO, Ernst CW, Newcom D, Steibel JP. Estimation of genome-wide and locus-specific
#' breed composition in pigs. Transl Anim Sci. 2017 Feb 1;1(1):36-44.
#'
#' @examples
#' # Example inputs for solve_composition_poly (ploidy = 4)
#'
#' # (This would typically be the output from allele_freq_poly)
#' allele_freqs_matrix <- matrix(
#' c(0.625, 0.500,
#' 0.500, 0.500,
#' 0.500, 0.500,
#' 0.750, 0.500,
#' 0.625, 0.625),
#' nrow = 5, ncol = 2, byrow = TRUE,
#' dimnames = list(paste0("SNP", 1:5), c("VarA", "VarB"))
#' )
#'
#' # Validation Genotypes (individuals x SNPs)
#' val_geno_matrix <- matrix(
#' c(2, 1, 2, 3, 4, # Test1 dosages for SNP1-5
#' 3, 4, 2, 3, 0), # Test2 dosages for SNP1-5
#' nrow = 2, ncol = 5, byrow = TRUE,
#' dimnames = list(paste0("Test", 1:2), paste0("SNP", 1:5))
#' )
#'
#' # Calculate Breed Composition
#' composition <- solve_composition_poly(Y = val_geno_matrix,
#' X = allele_freqs_matrix,
#' ploidy = 4)
#' print(composition)
#'
#' @export
solve_composition_poly <- function(Y,
X,
Expand Down
164 changes: 0 additions & 164 deletions R/breedtoos_functions.R

This file was deleted.

Loading