From 94069c4270bbe3dec2dfe767e8f5b41cad60325b Mon Sep 17 00:00:00 2001 From: yixuanchen <116841407+yixuan-chen-elisa@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:21:03 -0400 Subject: [PATCH 1/4] Update strand information in read.modkit.R --- R/read.modkit.R | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/R/read.modkit.R b/R/read.modkit.R index d4f6af2..ba77f49 100644 --- a/R/read.modkit.R +++ b/R/read.modkit.R @@ -15,7 +15,8 @@ read.modkit <- function(files, if (length(unique(data$V4)) == 2){ gr <- GRanges(seqnames = data[data$V4 == "m", ]$V1, ranges = IRanges(start = data[data$V4 == "m", ]$V2+1, - end = data[data$V4 == "m", ]$V3)) + end = data[data$V4 == "m", ]$V3), + strand = data[data$V4 == "m", ]$V6) mcols(gr)$m <- data[data$V4 == "m", ]$V12 mcols(gr)$h <- data[data$V4 != "m", ]$V12 @@ -23,7 +24,8 @@ read.modkit <- function(files, mcols(gr)$filter <- data[data$V4 == "m", ]$V16 }else{ gr <- GRanges(seqnames = data$V1, - ranges = IRanges(start = data$V2+1, end = data$V3)) + ranges = IRanges(start = data$V2+1, end = data$V3), + strand = data$V6) mcols(gr)$m <- data$V12 mcols(gr)$u <- data$V13 @@ -61,7 +63,9 @@ read.modkit <- function(files, parameters = NULL, pData = colData, gr = NULL, chr = as.vector(seqnames(overlap_gr)), sampleNames = sampleNames, rmZeroCov = rmZeroCov) - if (strandCollapse) {strandCollapse(bsseq_obj)} + if (strandCollapse) { + bsseq_obj <- strandCollapse(bsseq_obj) + } }else{ bsseq_obj <- BSseq(M = as.matrix(m), Cov = as.matrix(u + m), Filtered = as.matrix(filter), @@ -70,7 +74,9 @@ read.modkit <- function(files, parameters = NULL, pData = colData, gr = NULL, chr = as.vector(seqnames(overlap_gr)), sampleNames = sampleNames, rmZeroCov = rmZeroCov) - if (strandCollapse) {strandCollapse(bsseq_obj)} + if (strandCollapse) { + bsseq_obj <- strandCollapse(bsseq_obj) + } } return(bsseq_obj) From 39ac79f179b07d80bdd4766165fc2e5a0bb6917f Mon Sep 17 00:00:00 2001 From: yixuanchen <116841407+yixuan-chen-elisa@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:36:20 -0400 Subject: [PATCH 2/4] Update strand information in read.modkit.R --- R/read.modkit.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/read.modkit.R b/R/read.modkit.R index ba77f49..20ea8f9 100644 --- a/R/read.modkit.R +++ b/R/read.modkit.R @@ -11,6 +11,7 @@ read.modkit <- function(files, for (i in seq_along(files)){ data <- read.table(files[i], header = FALSE, sep="\t", stringsAsFactors=FALSE, quote="") + data$V6[data$V6 == "."] <- "*" if (length(unique(data$V4)) == 2){ gr <- GRanges(seqnames = data[data$V4 == "m", ]$V1, From f4bb6e8a43a5ba44c56a778ce545c71dad914ea8 Mon Sep 17 00:00:00 2001 From: yixuanchen <116841407+yixuan-chen-elisa@users.noreply.github.com> Date: Fri, 19 Apr 2024 14:56:40 -0400 Subject: [PATCH 3/4] Update strand information for read.modkit.R --- R/read.modkit.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/read.modkit.R b/R/read.modkit.R index 20ea8f9..01fe208 100644 --- a/R/read.modkit.R +++ b/R/read.modkit.R @@ -61,7 +61,7 @@ read.modkit <- function(files, Filtered = as.matrix(filter), coef = NULL, se.coef = NULL, pos = start(overlap_gr), trans = NULL, - parameters = NULL, pData = colData, gr = NULL, + parameters = NULL, pData = colData, gr = overlap_gr, chr = as.vector(seqnames(overlap_gr)), sampleNames = sampleNames, rmZeroCov = rmZeroCov) if (strandCollapse) { @@ -72,7 +72,7 @@ read.modkit <- function(files, Filtered = as.matrix(filter), coef = NULL, se.coef = NULL, pos = start(overlap_gr), trans = NULL, - parameters = NULL, pData = colData, gr = NULL, + parameters = NULL, pData = colData, gr = overlap_gr, chr = as.vector(seqnames(overlap_gr)), sampleNames = sampleNames, rmZeroCov = rmZeroCov) if (strandCollapse) { From b8886bc930c5858c200b68149790f3b38b4d8f42 Mon Sep 17 00:00:00 2001 From: yixuanchen <116841407+yixuan-chen-elisa@users.noreply.github.com> Date: Mon, 29 Apr 2024 17:10:07 -0400 Subject: [PATCH 4/4] Update read.modkit.R - change read.table to fread --- R/read.modkit.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/read.modkit.R b/R/read.modkit.R index 01fe208..b79158d 100644 --- a/R/read.modkit.R +++ b/R/read.modkit.R @@ -9,7 +9,7 @@ read.modkit <- function(files, } for (i in seq_along(files)){ - data <- read.table(files[i], header = FALSE, sep="\t", + data <- fread(files[i], header = FALSE, sep="\t", stringsAsFactors=FALSE, quote="") data$V6[data$V6 == "."] <- "*"