vec <- readdepth_uniq[[tids[i]]]
stopifnot(!is.null(vec))
if (is.na(vec[[2]])) wiggle_uniq <- rep(0, vec[[1]]) else wiggle_uniq <- as.numeric(unlist(strsplit(vec[[2]], split = " ")))
-# stopifnot(len == length(wiggle_uniq), len == sum(wiggle >= wiggle_uniq))
+ stopifnot(len == length(wiggle_uniq))
+ if (len != sum(wiggle >= wiggle_uniq)) {
+ cat("Warning: transcript ", tids[i], " has position(s) that read covarege with multireads is smaller than read covarge without multireads.\n", " The 1-based position(s) is(are) : ", which(wiggle < wiggle_uniq), ".\n", " This may be due to floating point arithmetics.\n", sep = "")
+ }
+
heights <- rbind(wiggle_uniq, wiggle - wiggle_uniq)
barplot(heights, space = 0, border = NA, names.arg = 1:len, col = c("black", "red"))
}
bool no_fractional_weight = false;
void add_bam_record_to_wiggle(const bam1_t *b, Wiggle& wiggle) {
- float w;
+ double w;
if (no_fractional_weight) w = 1.0;
else {
sp = ep = -1;
for (size_t i = 0; i < wiggle.length; i++) {
- if (wiggle.read_depth[i] > 0) {
+ if (wiggle.read_depth[i] >= 0.0095) {
ep = i;
}
else {
if (sp < ep) {
++sp;
fprintf(fo, "fixedStep chrom=%s start=%d step=1\n", wiggle.name.c_str(), sp + 1);
- for (int j = sp; j <= ep; j++) fprintf(fo, "%.7g\n", wiggle.read_depth[j]);
+ for (int j = sp; j <= ep; j++) fprintf(fo, "%.2f\n", wiggle.read_depth[j]);
}
sp = i;
}
if (sp < ep) {
++sp;
fprintf(fo, "fixedStep chrom=%s start=%d step=1\n", wiggle.name.c_str(), sp + 1);
- for (int j = sp; j <= ep; j++) fprintf(fo, "%.7g\n", wiggle.read_depth[j]);
+ for (int j = sp; j <= ep; j++) fprintf(fo, "%.2f\n", wiggle.read_depth[j]);
}
}