Skip to content

Commit 104c83f

Browse files
Merge pull request #25 from Breeding-Insight/test_updates
Test updates
2 parents 59de99f + f50a6d6 commit 104c83f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2151
-356
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
^LICENSE\.md$
66
^revdep$
77
^cran-comments\.md$
8+
^.github$

DESCRIPTION

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
Package: BIGr
2-
Title: Breeding Insight Genomics Functions for Polypoid and Diploid Species
2+
Title: Breeding Insight Genomics Functions for Polypoid and Diploid
3+
Species
34
Version: 0.5.0
45
Author: Alexander M. Sandercock, Cristiane H. Taniguti, Josue
56
Chinchilla-Vargas, Shufen Chen, Manoj Sapkota, Meng Lin, Dongyan Zhao,
67
and Breeding Insight Team
78
Maintainer: Alexander M. Sandercock <[email protected]>
8-
Description: Functions developed within Breeding Insight to analyze diploid and polyploid
9-
breeding and genetic data. 'BIGr' provides the ability to filter VCF files, extract SNPs from the DArT MADC file,
10-
and manipulate genotype data for both diploid and polyploid species. It also serves
11-
as the core dependency for the 'BIGapp' Shiny app, which provides a user-friendly interface for performing routine genotype analysis tasks
12-
such as dosage calling, filtering, PCA, GWAS, and Genomic Prediction.
9+
Description: Functions developed within Breeding Insight to analyze
10+
diploid and polyploid breeding and genetic data. 'BIGr' provides the
11+
ability to filter VCF files, extract SNPs from the DArT MADC file, and
12+
manipulate genotype data for both diploid and polyploid species. It
13+
also serves as the core dependency for the 'BIGapp' Shiny app, which
14+
provides a user-friendly interface for performing routine genotype
15+
analysis tasks such as dosage calling, filtering, PCA, GWAS, and
16+
Genomic Prediction.
17+
License: Apache License (>= 2)
1318
URL: https://github.com/Breeding-Insight/BIGr
1419
BugReports: https://github.com/Breeding-Insight/BIGr/issues
15-
License: Apache License (>= 2)
1620
Depends:
1721
R (>= 4.4.0)
1822
Imports:
@@ -24,6 +28,7 @@ Imports:
2428
methods,
2529
parallel,
2630
pwalign,
31+
quadprog,
2732
Rdpack (>= 0.7),
2833
readr (>= 2.1.5),
2934
reshape2 (>= 1.4.4),
@@ -33,7 +38,7 @@ Imports:
3338
utils,
3439
vcfR (>= 1.15.0)
3540
Suggests:
36-
testthat (>= 3.0.0)
41+
testthat (>= 3.0.0)
3742
RdMacros:
3843
Rdpack
3944
Encoding: UTF-8

NAMESPACE

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
# Generated by roxygen2: do not edit by hand
22

3-
export(add_ref_alt)
3+
export(allele_freq_poly)
44
export(calculate_Het)
55
export(calculate_MAF)
66
export(capture_diversity.Gmat)
77
export(check_ped)
8-
export(compare)
9-
export(create_VCF_body)
108
export(dosage2vcf)
119
export(dosage_ratios)
1210
export(filterVCF)
1311
export(flip_dosage)
1412
export(get_OffTargets)
1513
export(get_countsMADC)
16-
export(get_ref_alt_hap_seq)
1714
export(imputation_concordance)
18-
export(loop_though_dartag_report)
1915
export(madc2vcf)
2016
export(merge_MADCs)
21-
export(merge_counts)
17+
export(solve_composition_poly)
2218
export(updog2vcf)
2319
import(doParallel)
2420
import(dplyr)
2521
import(foreach)
2622
import(janitor)
2723
import(parallel)
24+
import(quadprog)
2825
import(tibble)
2926
import(tidyr)
3027
import(vcfR)
@@ -37,6 +34,7 @@ importFrom(pwalign,pairwiseAlignment)
3734
importFrom(readr,read_csv)
3835
importFrom(reshape2,dcast)
3936
importFrom(reshape2,melt)
37+
importFrom(stats,cor)
4038
importFrom(stats,lm)
4139
importFrom(stats,qt)
4240
importFrom(stats,sd)

R/breedtools_functions.R

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,35 @@
11
#' Computes allele frequencies for specified populations given SNP array data
22
#'
3-
#' @param geno matrix of genotypes coded as the dosage of allele B {0, 1, 2, ..., ploidy}
3+
#' @param geno matrix of genotypes coded as the dosage of allele B \code{{0, 1, 2, ..., ploidy}}
44
#' with individuals in rows (named) and SNPs in columns (named)
55
#' @param populations list of named populations. Each population has a vector of IDs
66
#' that belong to the population. Allele frequencies will be derived from all animals
77
#' @param ploidy integer indicating the ploidy level (default is 2 for diploid)
88
#' @return data.frame consisting of allele_frequencies for populations (columns) for
99
#' each SNP (rows)
10+
#' @references Funkhouser SA, Bates RO, Ernst CW, Newcom D, Steibel JP. Estimation of genome-wide and locus-specific
11+
#' breed composition in pigs. Transl Anim Sci. 2017 Feb 1;1(1):36-44.
12+
#'
13+
#' @examples
14+
#' # Example inputs
15+
#' geno_matrix <- matrix(
16+
#' c(4, 1, 4, 0, # S1
17+
#' 2, 2, 1, 3, # S2
18+
#' 0, 4, 0, 4, # S3
19+
#' 3, 3, 2, 2, # S4
20+
#' 1, 4, 2, 3),# S5
21+
#' nrow = 4, ncol = 5, byrow = FALSE, # individuals=rows, SNPs=cols
22+
#' dimnames = list(paste0("Ind", 1:4), paste0("S", 1:5))
23+
#' )
24+
#'
25+
#'pop_list <- list(
26+
#' PopA = c("Ind1", "Ind2"),
27+
#' PopB = c("Ind3", "Ind4")
28+
#' )
29+
#'
30+
#' allele_freqs <- allele_freq_poly(geno = geno_matrix, populations = pop_list, ploidy = 4)
31+
#' print(allele_freqs)
32+
#'
1033
#' @export
1134
allele_freq_poly <- function(geno, populations, ploidy = 2) {
1235

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

3962

40-
# Performs whole genome breed composition prediction.
41-
#
42-
# @param Y numeric vector of genotypes (with names as SNPs) from a single animal.
43-
# coded as dosage of allele B {0, 1, 2}
44-
# @param X numeric matrix of allele frequencies from reference animals
45-
# @param p numeric indicating number of breeds represented in X
46-
# @param names character names of breeds
47-
# @return data.frame of breed composition estimates
48-
# @import quadprog
49-
# @export
63+
#' Performs whole genome breed composition prediction.
64+
#'
65+
#' @param Y numeric vector of genotypes (with names as SNPs) from a single animal.
66+
#' coded as dosage of allele B \code{{0, 1, 2, ..., ploidy}}
67+
#' @param X numeric matrix of allele frequencies from reference animals
68+
#' @param p numeric indicating number of breeds represented in X
69+
#' @param names character names of breeds
70+
#' @return data.frame of breed composition estimates
71+
#' @import quadprog
72+
#' @importFrom stats cor
73+
#' @references Funkhouser SA, Bates RO, Ernst CW, Newcom D, Steibel JP. Estimation of genome-wide and locus-specific
74+
#' breed composition in pigs. Transl Anim Sci. 2017 Feb 1;1(1):36-44.
75+
#'
76+
#' @noRd
5077
QPsolve <- function(Y, X) {
5178

5279
# Remove NAs from Y and remove corresponding
@@ -90,7 +117,7 @@ QPsolve <- function(Y, X) {
90117
#' batch of animals.
91118
#'
92119
#' @param Y numeric matrix of genotypes (columns) from all animals (rows) in population
93-
#' coded as dosage of allele B {0, 1, ..., ploidy}
120+
#' coded as dosage of allele B \code{{0, 1, 2, ..., ploidy}}
94121
#' @param X numeric matrix of allele frequencies (rows) from each reference panel (columns). Frequencies are
95122
#' relative to allele B.
96123
#' @param ped data.frame giving pedigree information. Must be formatted "ID", "Sire", "Dam"
@@ -107,6 +134,37 @@ QPsolve <- function(Y, X) {
107134
#' @return A data.frame or list of data.frames (if groups is !NULL) with breed/ancestry composition
108135
#' results
109136
#' @import quadprog
137+
#' @references Funkhouser SA, Bates RO, Ernst CW, Newcom D, Steibel JP. Estimation of genome-wide and locus-specific
138+
#' breed composition in pigs. Transl Anim Sci. 2017 Feb 1;1(1):36-44.
139+
#'
140+
#' @examples
141+
#' # Example inputs for solve_composition_poly (ploidy = 4)
142+
#'
143+
#' # (This would typically be the output from allele_freq_poly)
144+
#' allele_freqs_matrix <- matrix(
145+
#' c(0.625, 0.500,
146+
#' 0.500, 0.500,
147+
#' 0.500, 0.500,
148+
#' 0.750, 0.500,
149+
#' 0.625, 0.625),
150+
#' nrow = 5, ncol = 2, byrow = TRUE,
151+
#' dimnames = list(paste0("SNP", 1:5), c("VarA", "VarB"))
152+
#' )
153+
#'
154+
#' # Validation Genotypes (individuals x SNPs)
155+
#' val_geno_matrix <- matrix(
156+
#' c(2, 1, 2, 3, 4, # Test1 dosages for SNP1-5
157+
#' 3, 4, 2, 3, 0), # Test2 dosages for SNP1-5
158+
#' nrow = 2, ncol = 5, byrow = TRUE,
159+
#' dimnames = list(paste0("Test", 1:2), paste0("SNP", 1:5))
160+
#' )
161+
#'
162+
#' # Calculate Breed Composition
163+
#' composition <- solve_composition_poly(Y = val_geno_matrix,
164+
#' X = allele_freqs_matrix,
165+
#' ploidy = 4)
166+
#' print(composition)
167+
#'
110168
#' @export
111169
solve_composition_poly <- function(Y,
112170
X,

R/breedtoos_functions.R

Lines changed: 0 additions & 164 deletions
This file was deleted.

0 commit comments

Comments
 (0)