-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating documentation and eliminating C++11 requirement
- Loading branch information
Showing
5 changed files
with
56 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
#' Look at genotypes that were imputed or changed by the HMM chain given a level of global genotypic error | ||
#' Display genotypes imputed or changed by the HMM chain given a global genotypic error | ||
#' | ||
#' Outputs a graphical representation ggplot with the percent of data changed. | ||
#' | ||
#' Most recent update 8/29/2023: | ||
#' -fixed issue where only worked on tetraploid to now working for diploid to octaploid. | ||
#' -un-hardcoded linkage groups in maps. previously hard-coded for tetraploid rose. | ||
#' | ||
#' | ||
#' @param map_list a list of multiple \code{mappoly.map.list} | ||
#' | ||
#' @param error error rate used in global error in the `calc_genoprob_error()` | ||
#' @param verbose T or F for `calc_genoprob_error()` and `calc_homologprob()` | ||
#' @param output_corrected TRUE or FALSE, if F only the ggplot of the changed dosage is printed, if T then a new corrected dosage matrix is output. | ||
#' @param verbose if TRUE (default), current progress is shown; if FALSE, | ||
#' no output is produced | ||
#' @param output_corrected logical. if FALSE only the ggplot of the changed | ||
#' dosage is printed, if TRUE then a new corrected dosage matrix is output. | ||
#' | ||
#' @return A ggplot of the changed and imputed genotypic dosages | ||
#' | ||
#' @examples | ||
#' x <- get_submap(solcap.err.map[[1]], 1:30, reestimate.rf = FALSE) # subset to run fast in tests | ||
#' plot_progeny_dosage_change(list(x), error=0.05, output_corrected=F) # no new corrected dosages | ||
#' corrected_matrix <- plot_progeny_dosage_change(list(x), error=0.05, output_corrected=F) #output corrected | ||
#' x <- get_submap(solcap.err.map[[1]], 1:30, reestimate.rf = FALSE) | ||
#' plot_progeny_dosage_change(list(x), error=0.05, output_corrected=FALSE) | ||
#' corrected_matrix <- plot_progeny_dosage_change(list(x), error=0.05, | ||
#' output_corrected=FALSE) #output corrected | ||
#' | ||
#' @author Jeekin Lau, \email{[email protected]}, with optimization by Cristiane Taniguti, \email{[email protected]} | ||
#' @author Jeekin Lau, \email{[email protected]}, with optimization by Cristiane | ||
#' Taniguti, \email{[email protected]} | ||
#' | ||
#' @import ggplot2 | ||
#' @import reshape2 | ||
#' @export plot_progeny_dosage_change | ||
|
||
plot_progeny_dosage_change <- function(map_list, error, verbose=T, output_corrected=F){ | ||
plot_progeny_dosage_change <- function(map_list, | ||
error, | ||
verbose = TRUE, | ||
output_corrected = FALSE){ | ||
Var1 <- Var2 <- value <- NULL | ||
map=map_list | ||
if(!exists(map[[1]]$info$data.name)) stop("mappoly.data object not here") | ||
|
@@ -38,7 +40,8 @@ plot_progeny_dosage_change <- function(map_list, error, verbose=T, output_correc | |
|
||
genoprob <- vector("list", length(map)) | ||
for(i in 1:length(map)){ | ||
genoprob[[i]] <- calc_genoprob_error(input.map = map[[i]], error = error, verbose = verbose) | ||
genoprob[[i]] <- calc_genoprob_error(input.map = map[[i]], error = error, | ||
verbose = verbose) | ||
} | ||
|
||
print("calculating homologprob") | ||
|
@@ -47,8 +50,8 @@ plot_progeny_dosage_change <- function(map_list, error, verbose=T, output_correc | |
|
||
print("comparing to orginal") | ||
|
||
P=unlist(lapply(map, function(x) x$maps[[1]]$seq.ph$P), recursive=F) | ||
Q=unlist(lapply(map, function(x) x$maps[[1]]$seq.ph$Q), recursive=F) | ||
P=unlist(lapply(map, function(x) x$maps[[1]]$seq.ph$P), recursive=FALSE) | ||
Q=unlist(lapply(map, function(x) x$maps[[1]]$seq.ph$Q), recursive=FALSE) | ||
|
||
|
||
|
||
|
@@ -92,7 +95,7 @@ plot_progeny_dosage_change <- function(map_list, error, verbose=T, output_correc | |
|
||
test <- sapply(homoprob_ind, function(x) { | ||
by_marker <- split.data.frame(x, x[,1]) | ||
final_matrix <- t(sapply(by_marker, function(y) y[order(y[,4], decreasing = T),][1:ploidy,2])) | ||
final_matrix <- t(sapply(by_marker, function(y) y[order(y[,4], decreasing = TRUE),][1:ploidy,2])) | ||
final_vector <- apply(final_matrix, 1, function(w) paste0(w, collapse = "")) | ||
return(final_vector) | ||
}) | ||
|
@@ -169,15 +172,15 @@ plot_progeny_dosage_change <- function(map_list, error, verbose=T, output_correc | |
empty_matrix[which(!original_geno==finished&!original_geno==ploidy+1)]="changed" | ||
empty_matrix_melt=melt(empty_matrix) | ||
plot1<-ggplot(empty_matrix_melt, aes(Var1, Var2, fill= factor(value, levels=c("changed","imputed","unchanged")))) + | ||
geom_tile()+scale_fill_manual(values=colors, drop=F)+ | ||
geom_tile()+scale_fill_manual(values=colors, drop=FALSE)+ | ||
xlab("Markers")+ | ||
ylab("Individuals")+ | ||
ggtitle(paste0("changed = ",round(percent_changed, digits=3),"% ","imputed = ", round(percent_imputed, digits=3),"%"))+ | ||
guides(fill=guide_legend(title="Dosage change")) | ||
print("done") | ||
|
||
print(plot1) | ||
if (output_corrected ==T){ | ||
if (output_corrected ==TRUE){ | ||
mrk_names=rownames(finished) | ||
mrk_index=which(dat$mrk.names%in%mrk_names) | ||
P1 = dat$dosage.p1[mrk_index] | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters