R/get_diff_values.R

Defines functions get_diff_values

Documented in get_diff_values

##' This is an internal function, which uses the results from the
##' function \code{\link{get_pca_window_list}} to generate the
##' differences in the k-mer distribution between two samples.
##'
##' This is an internal function.
##' @title Get the difference in counts between to sequences
##' @param list generated by \code{\link{get_pca_window_list}}
##' @return data.frame including the PCA coordinates and the radius
##'   differences
##' @author Jochen Kruppa
get_diff_values <- function(list){
  vir_1 <- list[[1]]$pca_plot_sphere_df
  vir_2 <- list[[2]]$pca_plot_sphere_df
  joined <- left_join(vir_1, vir_2, by = c("ind" = "ind"))
  radius_df <- tibble(PC1 = joined$PC1.x,
                      PC2 = joined$PC2.x,
                      PC3 = joined$PC3.x,
                      ## count_diff = joined$count.x.x - joined$count.x.y,
                      ## radius_diff = (0.15/max(abs(count_diff))) * count_diff, 
                      radius_diff = joined$count_radius.x - joined$count_radius.y,
                      radius_abs = abs(radius_diff),
                      radius_sign = sign(radius_diff),
                      ind = joined$ind)
  return(radius_df)
}
jkruppa/acgtPyramid documentation built on May 19, 2019, 12:45 p.m.