Skip to content

Commit

Permalink
bug fix: generating rcMethlvl table fixed, updated dataRead and bootm…
Browse files Browse the repository at this point in the history
…odel
  • Loading branch information
shahryary committed Jun 6, 2020
1 parent 0a67a4c commit 3497a14
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 47 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: AlphaBeta
Type: Package
Title: Computational inference of epimutation rates and spectra from high-throughput DNA methylation data in plants
Version: 1.3.2
Version: 1.3.3
Authors@R: c(
person("Yadollah", "Shahryary Dizaji", email = "[email protected]", role = c("cre","aut")),
person("Frank", "Johannes", email = "[email protected]", role = "aut"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ Changes in version 1.2.1 (2020-04-20)
+ Added some plots.
* Added SOMA functions.
* Plotting estimates

Changes in version 1.2.3 (2020-06-06)
* Fixed bugs.
* Compatible with new version of dplyr,data.tables
76 changes: 38 additions & 38 deletions R/BOOTmodel.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ BOOTmodel<-function(pedigree.data, Nboot, out.dir, out.name)
{

## Reading the dataset for bootstrapping and extracting the parameter settings
settings<-pedigree.data$settings
est<-pedigree.data$estimates
eqp<-as.numeric(as.character(settings[which(settings[,1] == "eqp"),2]))
eqp.weight<-as.numeric(as.character(settings[which(settings[,1] == "eqp.weight"),2]))
optim.method<-as.character(settings[which(settings[,1] == "optim.method"),2])
p0mm<-as.numeric(as.character(settings[which(settings[,1] == "p0mm"),2]))
p0uu<-as.numeric(as.character(settings[which(settings[,1] == "p0uu"),2]))
p0um<-1-(p0mm + p0uu)
pedigree<-pedigree.data$pedigree
settings<-pedigree.data$settings
est<-pedigree.data$estimates
eqp<-as.numeric(as.character(settings[which(settings[,1] == "eqp"),2]))
eqp.weight<-as.numeric(as.character(settings[which(settings[,1] == "eqp.weight"),2]))
optim.method<-as.character(settings[which(settings[,1] == "optim.method"),2])
#p0mm<-round(as.numeric(as.character(settings[which(settings[,1] == "p0mm"),2])),16)
p0uu<-round(as.numeric(as.character(settings[which(settings[,1] == "p0uu"),2])),16)
#p0um<-round(as.numeric(as.character(settings[which(settings[,1] == "p0um"),2])),15)
pedigree<-pedigree.data$pedigree
p0mm = 1-p0uu
p0um = 0


if(sum(c(p0mm, p0um, p0uu), na.rm =TRUE) != 1) {stop("The initial state probabilities don't sum to 1")}
Expand Down Expand Up @@ -258,10 +260,10 @@ BOOTmodel<-function(pedigree.data, Nboot, out.dir, out.name)
eqp<-as.numeric(as.character(settings[which(settings[,1] == "eqp"),2]))
eqp.weight<-as.numeric(as.character(settings[which(settings[,1] == "eqp.weight"),2]))
optim.method<-as.character(settings[which(settings[,1] == "optim.method"),2])
p0mm<-as.numeric(as.character(settings[which(settings[,1] == "p0mm"),2]))
p0uu<-as.numeric(as.character(settings[which(settings[,1] == "p0uu"),2]))
p0um<-1-(p0mm + p0uu)
p0uu<-round(as.numeric(as.character(settings[which(settings[,1] == "p0uu"),2])),16)
pedigree<-pedigree.data$pedigree
p0mm = 1-p0uu
p0um = 0


if(sum(c(p0mm, p0um, p0uu), na.rm =TRUE) != 1) {stop("The initial state probabilities don't sum to 1")}
Expand Down Expand Up @@ -477,11 +479,10 @@ BOOTmodel<-function(pedigree.data, Nboot, out.dir, out.name)
eqp<-as.numeric(as.character(settings[which(settings[,1] == "eqp"),2]))
eqp.weight<-as.numeric(as.character(settings[which(settings[,1] == "eqp.weight"),2]))
optim.method<-as.character(settings[which(settings[,1] == "optim.method"),2])
p0mm<-as.numeric(as.character(settings[which(settings[,1] == "p0mm"),2]))
p0uu<-as.numeric(as.character(settings[which(settings[,1] == "p0uu"),2]))
p0um<-1-(p0mm + p0uu)
sel<-as.numeric(as.character(settings$Setting[6]))
p0uu<-round(as.numeric(as.character(settings[which(settings[,1] == "p0uu"),2])),16)
pedigree<-pedigree.data$pedigree
p0mm = 1-p0uu
p0um = 0


if(sum(c(p0mm, p0um, p0uu), na.rm =TRUE) != 1) {stop("The initial state probabilities don't sum to 1")}
Expand Down Expand Up @@ -700,11 +701,10 @@ BOOTmodel<-function(pedigree.data, Nboot, out.dir, out.name)
eqp<-as.numeric(as.character(settings[which(settings[,1] == "eqp"),2]))
eqp.weight<-as.numeric(as.character(settings[which(settings[,1] == "eqp.weight"),2]))
optim.method<-as.character(settings[which(settings[,1] == "optim.method"),2])
p0mm<-as.numeric(as.character(settings[which(settings[,1] == "p0mm"),2]))
p0uu<-as.numeric(as.character(settings[which(settings[,1] == "p0uu"),2]))
p0um<-1-(p0mm + p0uu)
sel<-as.numeric(as.character(settings$Setting[6]))
p0uu<-round(as.numeric(as.character(settings[which(settings[,1] == "p0uu"),2])),16)
pedigree<-pedigree.data$pedigree
p0mm = 1-p0uu
p0um = 0


if(sum(c(p0mm, p0um, p0uu), na.rm =TRUE) != 1) {stop("The initial state probabilities don't sum to 1")}
Expand Down Expand Up @@ -919,15 +919,15 @@ BOOTmodel<-function(pedigree.data, Nboot, out.dir, out.name)
if (model == "ABneutral.R")
{
## Reading the dataset for bootstrapping and extracting the parameter settings
settings<-pedigree.data$settings
est<-pedigree.data$estimates
eqp<-as.numeric(as.character(settings[which(settings[,1] == "eqp"),2]))
eqp.weight<-as.numeric(as.character(settings[which(settings[,1] == "eqp.weight"),2]))
optim.method<-as.character(settings[which(settings[,1] == "optim.method"),2])
p0mm<-as.numeric(as.character(settings[which(settings[,1] == "p0mm"),2]))
p0uu<-as.numeric(as.character(settings[which(settings[,1] == "p0uu"),2]))
p0um<-1-(p0mm + p0uu)
pedigree<-pedigree.data$pedigree
settings<-pedigree.data$settings
est<-pedigree.data$estimates
eqp<-as.numeric(as.character(settings[which(settings[,1] == "eqp"),2]))
eqp.weight<-as.numeric(as.character(settings[which(settings[,1] == "eqp.weight"),2]))
optim.method<-as.character(settings[which(settings[,1] == "optim.method"),2])
p0uu<-round(as.numeric(as.character(settings[which(settings[,1] == "p0uu"),2])),16)
pedigree<-pedigree.data$pedigree
p0mm = 1-p0uu
p0um = 0


if(sum(c(p0mm, p0um, p0uu), na.rm =TRUE) != 1) {stop("The initial state probabilities don't sum to 1")}
Expand Down Expand Up @@ -1102,15 +1102,15 @@ allow.neg.intercept="yes"


##### Reading the dataset for bootstrapping and extracting the parameter settings
settings<-pedigree.data$settings
est<-pedigree.data$estimates
eqp<-as.numeric(as.character(settings[which(settings[,1] == "eqp"),2]))
eqp.weight<-as.numeric(as.character(settings[which(settings[,1] == "eqp.weight"),2]))
optim.method<-as.character(settings[which(settings[,1] == "optim.method"),2])
p0mm<-as.numeric(as.character(settings[which(settings[,1] == "p0mm"),2]))
p0uu<-as.numeric(as.character(settings[which(settings[,1] == "p0uu"),2]))
p0um<-1-(p0mm + p0uu)
pedigree<-pedigree.data$pedigree
settings<-pedigree.data$settings
est<-pedigree.data$estimates
eqp<-as.numeric(as.character(settings[which(settings[,1] == "eqp"),2]))
eqp.weight<-as.numeric(as.character(settings[which(settings[,1] == "eqp.weight"),2]))
optim.method<-as.character(settings[which(settings[,1] == "optim.method"),2])
p0uu<-round(as.numeric(as.character(settings[which(settings[,1] == "p0uu"),2])),16)
pedigree<-pedigree.data$pedigree
p0mm = 1-p0uu
p0um = 0
#props<-pedigree.data$prop.data.used


Expand Down
4 changes: 2 additions & 2 deletions R/dataRead.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ DM.dataRead <- function(dFile, cytosine, posteriorMaxFilter) {


drops <- c("context", "posteriorMax")
tmp <- tmp %>% select(!(drops))
tmp <- tmp %>% select(!all_of(drops))
#tmp <- tmp[ !(names(tmp) %in% drops)]
# filter out based on context & posteriorMax

Expand Down Expand Up @@ -83,7 +83,7 @@ RC.dataRead <- function(dFile, cytosine, posteriorMaxFilter) {
# filter out based on context & posteriorMax
drops <- c("context", "posteriorMax")
#tmp <- tmp[,!(names(tmp) %in% drops)]
tmp <- tmp %>% select(!(drops))
tmp <- tmp %>% select(!all_of(drops))
return(tmp)
}

Expand Down
13 changes: 7 additions & 6 deletions R/rcMethlvl.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,18 @@ RCsaveResult<-function(list.rc,cytosine,posteriorMaxFilter){
tmp_dmr <- data.frame(matrix(ncol = 3, nrow =1 ))
x <- c("Sample_name", "context", "rc.meth.lvls")
colnames(tmp_dmr) <- x
mainRC<-NULL
mainRC <- tmp_dmr
for (nlist in seq_len(length(list.rc))){
tmp_dmr$Sample_name<-list.rc[[nlist]][[1]]
tmp_dmr$Sample_name<-list.rc[[nlist]][[1]]$node
tmp_dmr$context<-cytosine
tmp_dmr$rc.meth.lvls <-list.rc[[nlist]][[2]]
mainRC<-rbind(mainRC,tmp_dmr)
tmp_dmr<-NULL
}
mainRC<-mainRC[mixedorder(mainRC$Sample_name),]
#saveFile <- paste0(getwd(), "/", "AB-methProp-", cytosine, "-", posteriorMaxFilter, ".csv")
#fwrite(mainRC,file = saveFile ,quote = FALSE,sep = '\t',row.names = FALSE,col.names = TRUE)
#cat(paste0("Methylation proportions results saved in: ",saveFile,"\n"))
mainRC <- mainRC[!(rowSums(x = is.na(x = mainRC)) == ncol(x = mainRC)),]
rownames(mainRC) <- NULL
mainRC %>% mutate_if(is.factor, as.character) -> mainRC
mainRC <- mainRC[mixedorder(mainRC$Sample_name), ]
return(mainRC)

}
Expand Down

0 comments on commit 3497a14

Please sign in to comment.