Skip to content
Snippets Groups Projects
Commit 53017894 authored by Sascha Meiers's avatar Sascha Meiers
Browse files

More realistic count calculation - fixing bugs

parent e56f887b
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@ segs = fread(snakemake@input[["bp"]])
# is there a normalization file given?
if ("norm" %in% names(snakemake@input)) {
if ("norm" %in% names(snakemake@input) && length(snakemake@input[["norm"]])>0) {
message("[MosaiClassifier] Read normalization from ", snakemake@input[["norm"]])
normalization = fread(snakemake@input[["norm"]])
} else {
......
......@@ -36,18 +36,18 @@ addCountsPerSegment <- function(df, count_tab) {
setkey(counts,sample,cell, chrom, start, end)
# Add expected counts (old way)
probs[,
df[,
expected_old := (to - from +1)*mean,
by = .(sample, cell, chrom, from, to)]
# Add expected counts (new way)
counts[, num_bins := cumsum(class != "None"), by = .(sample, cell, chrom)]
xxx <- counts[, .(chrom_ = chrom, start_ = start, end_ = end, sample_ = sample, cell_ = cell, num_bins)]
probs[,
df[,
expected := xxx[sample_ == sample & cell_ == cell & chrom_ == chrom, num_bins[to] - num_bins[from] + 1] * mean,
by = .(sample, cell, chrom)]
unique(probs[, .(chrom, from, to)])
#unique(probs[, .(chrom, from, to)])
# Assign bin indices and check that all cells have the same bins!
counts[, idx := 1:.N, by = .(chrom, sample, cell)]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment