<commit_before>source("common.r")


OPT.LGDIST <- getArgument("LGDIST")
OPT.PDFOUT <- getArgument("PDFOUT")
OPT.MISINCORP <- getArgument("MISINCORP")
OPT.TITLE <- getArgument("TITLE")
OPT.VERSION <- getArgument("VERSION")

MISMATCHES <- c("C>T", "G>A")


plot.length.distribution <- function(tbl) {
  tbl <- aggregate(tbl$Occurences, tbl[, c("Kind", "Std", "Length")], sum)

  row <- 1
  data <- matrix(0, nrow = 4, ncol = max(tbl$Length))
  for (kind in c("se", "pe")) {
    for (strand in c("+", "-")) {
      # PE reads with unknown template lengths (Length = 0) are counted but not plotted
      subtbl <- subset(tbl, Std == strand & Kind == kind & Length > 0)

      data[row, subtbl$Length] <- subtbl$x
      row <- row + 1
    }
  }

  # The sum of space and width defines the width of each bar + padding
  space <- 0.2
  width <- 1.0

  # Start and end the axis on a number divisible by 10
  min_len <- floor(min(tbl$Length) / 10) * 10
  max_len <- ceiling(max(tbl$Length) / 10) * 10

  colors <- c(rgb(1:0, 0, 0:1, 1 / 2), grey.colors(3))
  barplot(data, width = width, space = space, border = NA, col = colors, axes = FALSE, axisnames = FALSE, main = "Length distribution", xlim = c(min_len, max_len) * (space + width))

  legend("topright",
    c("+ strand (SE)", "- strand (SE)", "+ strand (PE)", "- strand (PE)"),
    fill = colors, bty = "n", border = NA
  )

  mtext("Occurences", side = 2, line = 2.5, cex = 0.7)
  mtext("Read length", side = 1, line = 2, cex = 0.7)
  xcoord <- seq(min_len, max_len, 10)
  axis(side = 1, labels = xcoord, at = (xcoord - 0.5) * (width + space), las = 2, cex.axis = 0.6)
  axis(side = 2, labels = TRUE, las = 2, cex.axis = 0.6)
}

<commit_msg>fix xlim not using filtered lengths<commit_after>source("common.r")


OPT.LGDIST <- getArgument("LGDIST")
OPT.PDFOUT <- getArgument("PDFOUT")
OPT.MISINCORP <- getArgument("MISINCORP")
OPT.TITLE <- getArgument("TITLE")
OPT.VERSION <- getArgument("VERSION")

MISMATCHES <- c("C>T", "G>A")


plot.length.distribution <- function(tbl) {
  tbl <- aggregate(tbl$Occurences, tbl[, c("Kind", "Std", "Length")], sum)
  # PE reads with unknown template lengths (Length = 0) are counted but not plotted
  tbl <- subset(tbl, Length > 0)

  row <- 1
  data <- matrix(0, nrow = 4, ncol = max(tbl$Length))
  for (kind in c("se", "pe")) {
    for (strand in c("+", "-")) {
      subtbl <- subset(tbl, Std == strand & Kind == kind)

      data[row, subtbl$Length] <- subtbl$x
      row <- row + 1
    }
  }

  # The sum of space and width defines the width of each bar + padding
  space <- 0.2
  width <- 1.0

  # Start and end the axis on a number divisible by 10
  min_len <- floor(min(tbl$Length) / 10) * 10
  max_len <- ceiling(max(tbl$Length) / 10) * 10

  colors <- c(rgb(1:0, 0, 0:1, 1 / 2), grey.colors(3))
  barplot(data, width = width, space = space, border = NA, col = colors, axes = FALSE, axisnames = FALSE, main = "Length distribution", xlim = c(min_len, max_len) * (space + width))

  legend("topright",
    c("+ strand (SE)", "- strand (SE)", "+ strand (PE)", "- strand (PE)"),
    fill = colors, bty = "n", border = NA
  )

  mtext("Occurences", side = 2, line = 2.5, cex = 0.7)
  mtext("Read length", side = 1, line = 2, cex = 0.7)
  xcoord <- seq(min_len, max_len, 10)
  axis(side = 1, labels = xcoord, at = (xcoord - 0.5) * (width + space), las = 2, cex.axis = 0.6)
  axis(side = 2, labels = TRUE, las = 2, cex.axis = 0.6)
}


{'fraction_non_alphanumeric': 0.1847953216374269, 'fraction_numerical': 0.02865497076023392, 'mean_word_length': 3.197546012269939, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '881116', 'n_tokens_mistral': 1427, 'n_tokens_neox': 1251, 'n_words': 381}