Browse Source

ok all contigs graphs and stats

Your Name 1 năm trước cách đây
mục cha
commit
0be9290231
2 tập tin đã thay đổi với 13 bổ sung16 xóa
  1. 13 14
      src/counts.rs
  2. 0 2
      src/lib.rs

+ 13 - 14
src/counts.rs

@@ -2,7 +2,7 @@ use anyhow::Context;
 use log::{info, warn};
 use ordered_float::Float;
 use pandora_lib_graph::cytoband::{svg_chromosome, AdditionalRect, RectPosition};
-use plotly::{common::Marker, layout::BarMode, Bar, Layout, Plot, Scatter};
+use plotly::{color::Rgb, common::Marker, layout::BarMode, Bar, Layout, Plot, Scatter};
 use rand::{thread_rng, Rng};
 use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
 use serde::{
@@ -245,7 +245,12 @@ impl Counts {
         Ok(*data.get(index(percentile)).context("Error in percentile")?)
     }
 
-    pub fn save_contig(&mut self, contig: &str, prefix: &str, breaks: Vec<u32>) -> anyhow::Result<()> {
+    pub fn save_contig(
+        &mut self,
+        contig: &str,
+        prefix: &str,
+        breaks: Vec<u32>,
+    ) -> anyhow::Result<()> {
         self.mask_low_mrd(contig, 6)?;
         self.mask_low_quality(contig, 0.1)?;
 
@@ -268,18 +273,13 @@ impl Counts {
         let distribution_path = format!("{prefix}_{contig}_distrib.svg");
         info!("Saving graph: {distribution_path}");
         let mut plot = Plot::new();
-        let colors: Vec<plotly::color::Rgb> = data_x
+        let colors: Vec<Rgb> = data_x
             .iter()
-            .map(|&x| {
-                if x < 2.0 {
-                    plotly::color::Rgb::new(193, 18, 31)
-                } else if x >= 15.0 {
-                    plotly::color::Rgb::new(138, 201, 38)
-                } else if x < 6.0 {
-                    plotly::color::Rgb::new(243, 114, 44)
-                } else {
-                    plotly::color::Rgb::new(255, 202, 58)
-                }
+            .map(|&x| match x {
+                x if x < 2.0 => Rgb::new(193, 18, 31),
+                x if x < 6.0 => Rgb::new(243, 114, 44),
+                x if x < 15.0 => Rgb::new(255, 202, 58),
+                _ => Rgb::new(138, 201, 38),
             })
             .collect();
 
@@ -379,7 +379,6 @@ impl Counts {
             .collect();
 
         let hm = self.counts_annotations(contig)?;
-
         let len = d.len();
         let mut masked: Vec<(String, f64)> = hm
             .iter()

+ 0 - 2
src/lib.rs

@@ -435,8 +435,6 @@ mod tests {
                 .map(|c| format!("{result_dir}/{id}/mrd/scan/{c}_counts.tsv"))
                 .collect(),
         );
-        counts.mask_low_mrd(contig, 6)?;
-        counts.mask_low_quality(contig, 0.1)?;
         // let hm = counts.counts_annotations(contig)?;
 
         // let len = counts.data.get(contig).unwrap().len();