fixed pos_count cals in function by specifying dplyr and changed summarize to summarise

This commit is contained in:
Tanushree Tunstall 2021-09-15 15:46:42 +01:00
parent 6beb003de5
commit 664d43f717
3 changed files with 24 additions and 16 deletions

View file

@ -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,
digits = 2, method = "pearson", pch = 20, lm = FALSE, cor = TRUE,

View file

@ -42,7 +42,9 @@ site_snp_count_bp <- function (plotdf
, "\nNo. of cols:", ncol(plotdf)
, "\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)))]
cat("\nCumulative nssnp count\n"
@ -65,13 +67,18 @@ site_snp_count_bp <- function (plotdf
, "\nNo. of rows:", nrow(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
snpsBYpos_df <- plotdf %>%
group_by(eval(parse(text = df_colname))) %>%
summarize(snpsBYpos = mean(pos_count))
dplyr::group_by(eval(parse(text = df_colname))) %>%
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
tot_sites = sum(table(snpsBYpos_df$snpsBYpos))

View file

@ -6,7 +6,6 @@
#########################################################
#lib_loc = "/usr/local/lib/R/site-library")
require("getopt", quietly = TRUE) # cmd parse arguments
if (!require("tidyverse")) {
@ -19,6 +18,11 @@ if (!require("shiny")) {
library(shiny)
}
if (!require("shinyBS")) {
install.packages("shinyBS", dependencies = TRUE)
library(shinyBS)
}
if (!require("gridExtra")) {
install.packages("gridExtra", dependencies = TRUE)
library(gridExtra)
@ -39,6 +43,11 @@ if (!require("ggridges")) {
# library(dplyr)
# }
if (!require ("DT")){
install.packages("DT")
library(DT)
}
if (!require ("plyr")){
install.packages("plyr")
library(plyr)