fixed pos_count cals in function by specifying dplyr and changed summarize to summarise
This commit is contained in:
parent
6beb003de5
commit
664d43f717
3 changed files with 24 additions and 16 deletions
|
@ -38,14 +38,6 @@ my_corr_pairs <- function (corr_data_all
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c_plot <- my_corr_pairs(corrplot_df
|
|
||||||
|
|
||||||
, dot_size = 1.6
|
|
||||||
, ats = 1.5
|
|
||||||
, corr_lab_size = 1.5
|
|
||||||
, corr_value_size = 1)
|
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
my_pp = function (x, smooth = TRUE, scale = FALSE, density = TRUE, ellipses = TRUE,
|
my_pp = function (x, smooth = TRUE, scale = FALSE, density = TRUE, ellipses = TRUE,
|
||||||
digits = 2, method = "pearson", pch = 20, lm = FALSE, cor = TRUE,
|
digits = 2, method = "pearson", pch = 20, lm = FALSE, cor = TRUE,
|
||||||
|
|
|
@ -42,7 +42,9 @@ site_snp_count_bp <- function (plotdf
|
||||||
, "\nNo. of cols:", ncol(plotdf)
|
, "\nNo. of cols:", ncol(plotdf)
|
||||||
, "\nNow adding column: frequency of mutational positions"))
|
, "\nNow adding column: frequency of mutational positions"))
|
||||||
|
|
||||||
# adding snpcount for each position
|
#-------------------------------------------
|
||||||
|
# adding column: snpcount for each position
|
||||||
|
#-------------------------------------------
|
||||||
setDT(plotdf)[, pos_count := .N, by = .(eval(parse(text = df_colname)))]
|
setDT(plotdf)[, pos_count := .N, by = .(eval(parse(text = df_colname)))]
|
||||||
|
|
||||||
cat("\nCumulative nssnp count\n"
|
cat("\nCumulative nssnp count\n"
|
||||||
|
@ -64,15 +66,20 @@ site_snp_count_bp <- function (plotdf
|
||||||
cat(paste0("\nrevised df dimensions:"
|
cat(paste0("\nrevised df dimensions:"
|
||||||
, "\nNo. of rows:", nrow(plotdf)
|
, "\nNo. of rows:", nrow(plotdf)
|
||||||
, "\nNo. of cols:", ncol(plotdf)))
|
, "\nNo. of cols:", ncol(plotdf)))
|
||||||
|
|
||||||
|
#------------------------------------------------------
|
||||||
|
# creating df: average count of snpcount for each position
|
||||||
|
# created in earlier step
|
||||||
|
#-------------------------------------------------------
|
||||||
# use group by on pos_count
|
# use group by on pos_count
|
||||||
snpsBYpos_df <- plotdf %>%
|
snpsBYpos_df <- plotdf %>%
|
||||||
group_by(eval(parse(text = df_colname))) %>%
|
dplyr::group_by(eval(parse(text = df_colname))) %>%
|
||||||
summarize(snpsBYpos = mean(pos_count))
|
dplyr::summarise(snpsBYpos = mean(pos_count)) # changed from summarize!
|
||||||
|
|
||||||
cat("\nnssnp count\n"
|
|
||||||
, table(snpsBYpos_df$snpsBYpos))
|
|
||||||
|
|
||||||
|
cat("\nnssnp count per position\n"
|
||||||
|
, table(snpsBYpos_df$snpsBYpos)
|
||||||
|
, "\n")
|
||||||
|
|
||||||
# calculating total no. of sites associated with nsSNPs
|
# calculating total no. of sites associated with nsSNPs
|
||||||
tot_sites = sum(table(snpsBYpos_df$snpsBYpos))
|
tot_sites = sum(table(snpsBYpos_df$snpsBYpos))
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#########################################################
|
#########################################################
|
||||||
#lib_loc = "/usr/local/lib/R/site-library")
|
#lib_loc = "/usr/local/lib/R/site-library")
|
||||||
|
|
||||||
|
|
||||||
require("getopt", quietly = TRUE) # cmd parse arguments
|
require("getopt", quietly = TRUE) # cmd parse arguments
|
||||||
|
|
||||||
if (!require("tidyverse")) {
|
if (!require("tidyverse")) {
|
||||||
|
@ -19,6 +18,11 @@ if (!require("shiny")) {
|
||||||
library(shiny)
|
library(shiny)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!require("shinyBS")) {
|
||||||
|
install.packages("shinyBS", dependencies = TRUE)
|
||||||
|
library(shinyBS)
|
||||||
|
}
|
||||||
|
|
||||||
if (!require("gridExtra")) {
|
if (!require("gridExtra")) {
|
||||||
install.packages("gridExtra", dependencies = TRUE)
|
install.packages("gridExtra", dependencies = TRUE)
|
||||||
library(gridExtra)
|
library(gridExtra)
|
||||||
|
@ -39,6 +43,11 @@ if (!require("ggridges")) {
|
||||||
# library(dplyr)
|
# library(dplyr)
|
||||||
# }
|
# }
|
||||||
|
|
||||||
|
if (!require ("DT")){
|
||||||
|
install.packages("DT")
|
||||||
|
library(DT)
|
||||||
|
}
|
||||||
|
|
||||||
if (!require ("plyr")){
|
if (!require ("plyr")){
|
||||||
install.packages("plyr")
|
install.packages("plyr")
|
||||||
library(plyr)
|
library(plyr)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue