From 322de8eab1f8c82411769e73a71bc014264243f1 Mon Sep 17 00:00:00 2001 From: alphabdiallo Date: Wed, 4 Jun 2025 18:31:40 -0400 Subject: [PATCH 01/12] display flip flop only for ssAAV --- src/report.Rmd | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/report.Rmd b/src/report.Rmd index be07f04..e1aa984 100644 --- a/src/report.Rmd +++ b/src/report.Rmd @@ -543,28 +543,32 @@ if (file.exists(agg_flipflop_tsv)) { ```{r ffplot, message=FALSE, warning=FALSE, results='asis'} if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { - # Generate flip/flop summary plot - ffplot <- df.flipflop %>% - mutate( - class = if_else( - leftITR == 'unclassified' | rightITR == 'unclassified', - "unclassified", - paste(leftITR, rightITR, sep = '-') - ) - ) %>% - mutate( - unclass = if_else( class == "unclassified", "unclassified", "classified") - ) %>% - group_by(type, subtype, class, unclass) %>% - summarize(classct = sum(count)) %>% - filter(subtype == 'full') - ggplot(ffplot, aes(x = class, y = classct, fill = unclass)) + - geom_bar(stat = 'identity', show.legend = FALSE) + - labs(x = 'Assigned type') + - scale_y_continuous("Number of reads", - limits = c(0, NA), - expand = expansion(mult = c(0, 0.05))) - + if (params$vector_type == "ss") { + # Generate flip/flop summary plot + ffplot <- df.flipflop %>% + mutate( + class = if_else( + leftITR == 'unclassified' | rightITR == 'unclassified', + "unclassified", + paste(leftITR, rightITR, sep = '-') + ) + ) %>% + mutate( + unclass = if_else( class == "unclassified", "unclassified", "classified") + ) %>% + group_by(type, subtype, class, unclass) %>% + summarize(classct = sum(count)) %>% + filter(subtype == 'full') + ggplot(ffplot, aes(x = class, y = classct, fill = unclass)) + + geom_bar(stat = 'identity', show.legend = FALSE) + + labs(x = 'Assigned type') + + scale_y_continuous("Number of reads", + limits = c(0, NA), + expand = expansion(mult = c(0, 0.05))) + } + # } else if (params$vector_type == "sc") { + + # } } else { cat("No flip/flop analysis results available to display.") } From 181175598c29c9956d220028f378f1ad1b05cdd0 Mon Sep 17 00:00:00 2001 From: alphabdiallo Date: Thu, 5 Jun 2025 12:57:42 -0400 Subject: [PATCH 02/12] Removing flip flop table for sc --- src/report.Rmd | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/report.Rmd b/src/report.Rmd index e1aa984..33eb549 100644 --- a/src/report.Rmd +++ b/src/report.Rmd @@ -576,8 +576,12 @@ if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { ```{r fftable, message=FALSE, warning=FALSE, results='asis'} if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { - flextable(df.flipflop) %>% - set_header_labels(values = c("type", "subtype", "leftITR", "rightITR", "count")) + if (params$vector_type == "ss") { + flextable(df.flipflop) %>% + set_header_labels(values = c("type", "subtype", "leftITR", "rightITR", "count")) + } + # else if (params$vector_type == "sc") { + # } } ``` From 71d9a374cc3d464f031e66f0afdc345e96f5b443 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 5 Jun 2025 21:27:13 +0000 Subject: [PATCH 03/12] Adding sc flipflop logic --- src/report.Rmd | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/report.Rmd b/src/report.Rmd index 33eb549..e0e2776 100644 --- a/src/report.Rmd +++ b/src/report.Rmd @@ -565,10 +565,30 @@ if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { scale_y_continuous("Number of reads", limits = c(0, NA), expand = expansion(mult = c(0, 0.05))) + #} + } else if (params$vector_type == "sc") { + # Generate flip/flop summary plot + ffplot <- df.flipflop %>% + mutate( + class = if_else( + leftITR == 'unclassified', + "unclassified", + paste(leftITR, rightITR, sep = '-') + ) + ) %>% + mutate( + unclass = if_else( class == "unclassified", "unclassified") + ) %>% + group_by(type, subtype, class, unclass) %>% + summarize(classct = sum(count)) %>% + filter(subtype == 'full') + ggplot(ffplot, aes(x = class, y = classct, fill = unclass)) + + geom_bar(stat = 'identity', show.legend = FALSE) + + labs(x = 'Assigned type') + + scale_y_continuous("Number of reads", + limits = c(0, NA), + expand = expansion(mult = c(0, 0.05))) } - # } else if (params$vector_type == "sc") { - - # } } else { cat("No flip/flop analysis results available to display.") } @@ -580,8 +600,10 @@ if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { flextable(df.flipflop) %>% set_header_labels(values = c("type", "subtype", "leftITR", "rightITR", "count")) } - # else if (params$vector_type == "sc") { - # } + else if (params$vector_type == "sc") { + flextable(df.flipflop) %>% + set_header_labels(values = c("type", "subtype", "rightITR", "count")) + } } ``` From 14746db2ffbcb73a84ac8e1d03d3cb5befacbd38 Mon Sep 17 00:00:00 2001 From: alphabdiallo Date: Thu, 5 Jun 2025 22:00:01 +0000 Subject: [PATCH 04/12] updating sc flip flop --- src/report.Rmd | 1 - 1 file changed, 1 deletion(-) diff --git a/src/report.Rmd b/src/report.Rmd index e0e2776..61b1622 100644 --- a/src/report.Rmd +++ b/src/report.Rmd @@ -565,7 +565,6 @@ if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { scale_y_continuous("Number of reads", limits = c(0, NA), expand = expansion(mult = c(0, 0.05))) - #} } else if (params$vector_type == "sc") { # Generate flip/flop summary plot ffplot <- df.flipflop %>% From 55f2a34bc6f07c0cd460cf99caf444c9966d53f6 Mon Sep 17 00:00:00 2001 From: alphabdiallo Date: Fri, 6 Jun 2025 12:18:00 -0400 Subject: [PATCH 05/12] look at the rightITR for scAAV flip flop analysis --- src/report.Rmd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/report.Rmd b/src/report.Rmd index 61b1622..f253883 100644 --- a/src/report.Rmd +++ b/src/report.Rmd @@ -570,13 +570,13 @@ if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { ffplot <- df.flipflop %>% mutate( class = if_else( - leftITR == 'unclassified', + rightITR == 'unclassified', "unclassified", - paste(leftITR, rightITR, sep = '-') + "righITR" ) ) %>% mutate( - unclass = if_else( class == "unclassified", "unclassified") + unclass = if_else( class == "unclassified", "unclassified", "classified") ) %>% group_by(type, subtype, class, unclass) %>% summarize(classct = sum(count)) %>% From d8669565f6b59732e598e10361f881e50f0815c3 Mon Sep 17 00:00:00 2001 From: alphabdiallo Date: Fri, 6 Jun 2025 12:39:02 -0400 Subject: [PATCH 06/12] Fixing issue with sc flip flop table display --- src/report.Rmd | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/report.Rmd b/src/report.Rmd index f253883..19524df 100644 --- a/src/report.Rmd +++ b/src/report.Rmd @@ -600,8 +600,11 @@ if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { set_header_labels(values = c("type", "subtype", "leftITR", "rightITR", "count")) } else if (params$vector_type == "sc") { - flextable(df.flipflop) %>% - set_header_labels(values = c("type", "subtype", "rightITR", "count")) + # flextable(df.flipflop) %>% + # set_header_labels(values = c("type", "subtype", "leftITR", "rightITR", "count")) + flextable(df.flipflop %>% + set_header_labels(values = c("type", "subtype", "leftITR", "rightITR", "count")) %>% + select(type, subtype, rightITR, count)) } } ``` From 5ea0e0da24bb64330a7134f98ac827e44e99643d Mon Sep 17 00:00:00 2001 From: alphabdiallo Date: Fri, 6 Jun 2025 13:52:00 -0400 Subject: [PATCH 07/12] Fixing sc flexable --- src/report.Rmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/report.Rmd b/src/report.Rmd index 19524df..ce07dad 100644 --- a/src/report.Rmd +++ b/src/report.Rmd @@ -602,9 +602,9 @@ if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { else if (params$vector_type == "sc") { # flextable(df.flipflop) %>% # set_header_labels(values = c("type", "subtype", "leftITR", "rightITR", "count")) - flextable(df.flipflop %>% + flextable(df.flipflop) %>% set_header_labels(values = c("type", "subtype", "leftITR", "rightITR", "count")) %>% - select(type, subtype, rightITR, count)) + select(type, subtype, rightITR, count) } } ``` From da4c12f4d119ac4e268e04a802ef8dd2f7b24ca6 Mon Sep 17 00:00:00 2001 From: alphabdiallo Date: Fri, 6 Jun 2025 14:28:07 -0400 Subject: [PATCH 08/12] Printing flextable columns --- src/report.Rmd | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/report.Rmd b/src/report.Rmd index ce07dad..884b860 100644 --- a/src/report.Rmd +++ b/src/report.Rmd @@ -602,9 +602,10 @@ if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { else if (params$vector_type == "sc") { # flextable(df.flipflop) %>% # set_header_labels(values = c("type", "subtype", "leftITR", "rightITR", "count")) - flextable(df.flipflop) %>% - set_header_labels(values = c("type", "subtype", "leftITR", "rightITR", "count")) %>% - select(type, subtype, rightITR, count) + # flextable(df.flipflop) %>% + # set_header_labels(values = c("type", "subtype", "leftITR", "rightITR", "count")) %>% + # select(type, subtype, rightITR, count) + print(colnames(df.flipflop)) } } ``` From 83dc5e211f131d83a93bdca9aee27f7b4c01d724 Mon Sep 17 00:00:00 2001 From: alphabdiallo Date: Fri, 6 Jun 2025 14:49:00 -0400 Subject: [PATCH 09/12] Deplaxing sc ITR results --- src/report.Rmd | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/report.Rmd b/src/report.Rmd index 884b860..84221e5 100644 --- a/src/report.Rmd +++ b/src/report.Rmd @@ -572,7 +572,7 @@ if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { class = if_else( rightITR == 'unclassified', "unclassified", - "righITR" + paste(rightITR) ) ) %>% mutate( @@ -597,7 +597,8 @@ if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { if (params$vector_type == "ss") { flextable(df.flipflop) %>% - set_header_labels(values = c("type", "subtype", "leftITR", "rightITR", "count")) + set_header_labels(values = c("type" = "Type", "subtype" = "Subtype", "leftITR" = "Left ITR", "rightITR" = "Right ITR", "count" = "Count")) + } else if (params$vector_type == "sc") { # flextable(df.flipflop) %>% @@ -605,7 +606,11 @@ if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { # flextable(df.flipflop) %>% # set_header_labels(values = c("type", "subtype", "leftITR", "rightITR", "count")) %>% # select(type, subtype, rightITR, count) - print(colnames(df.flipflop)) + #print(colnames(df.flipflop)) + df.flipflop %>% + select(type, subtype, rightITR, count) %>% + flextable() %>% + set_header_labels(values = c("type" = "Type", "subtype" = "Subtype", "rightITR" = "Right ITR", "count" = "Count")) } } ``` From 79fda2c3cc51c9871c03a7403eb2959027cfcf5c Mon Sep 17 00:00:00 2001 From: alphabdiallo Date: Fri, 6 Jun 2025 15:09:05 -0400 Subject: [PATCH 10/12] aggregating counts of same ITR configutation --- src/report.Rmd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/report.Rmd b/src/report.Rmd index 84221e5..3c7b817 100644 --- a/src/report.Rmd +++ b/src/report.Rmd @@ -608,6 +608,8 @@ if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { # select(type, subtype, rightITR, count) #print(colnames(df.flipflop)) df.flipflop %>% + group_by(type, subtype, rightITR) %>% + summarize(count = sum(count), .groups = "drop") %>% select(type, subtype, rightITR, count) %>% flextable() %>% set_header_labels(values = c("type" = "Type", "subtype" = "Subtype", "rightITR" = "Right ITR", "count" = "Count")) From 9abbf08ad85bb7985bd053c6eb292d2b62590501 Mon Sep 17 00:00:00 2001 From: alphabdiallo Date: Tue, 10 Jun 2025 17:40:24 -0400 Subject: [PATCH 11/12] Adding logic to plot flip or flop for fulls and right-partials --- src/report.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/report.Rmd b/src/report.Rmd index 3c7b817..c62605c 100644 --- a/src/report.Rmd +++ b/src/report.Rmd @@ -580,7 +580,7 @@ if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { ) %>% group_by(type, subtype, class, unclass) %>% summarize(classct = sum(count)) %>% - filter(subtype == 'full') + filter(subtype == 'full' | subtype == 'right-partial') ggplot(ffplot, aes(x = class, y = classct, fill = unclass)) + geom_bar(stat = 'identity', show.legend = FALSE) + labs(x = 'Assigned type') + From 4caecf25450b82891a675caf637d9836aef904ee Mon Sep 17 00:00:00 2001 From: alphabdiallo Date: Tue, 10 Jun 2025 18:43:25 -0400 Subject: [PATCH 12/12] sc flip and flop only for fulls --- src/report.Rmd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/report.Rmd b/src/report.Rmd index c62605c..2189cb7 100644 --- a/src/report.Rmd +++ b/src/report.Rmd @@ -580,7 +580,7 @@ if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { ) %>% group_by(type, subtype, class, unclass) %>% summarize(classct = sum(count)) %>% - filter(subtype == 'full' | subtype == 'right-partial') + filter(subtype == 'full') ggplot(ffplot, aes(x = class, y = classct, fill = unclass)) + geom_bar(stat = 'identity', show.legend = FALSE) + labs(x = 'Assigned type') + @@ -611,6 +611,7 @@ if (exists("df.flipflop") && (nrow(df.flipflop) > 1)) { group_by(type, subtype, rightITR) %>% summarize(count = sum(count), .groups = "drop") %>% select(type, subtype, rightITR, count) %>% + filter(subtype == 'full' ) %>% flextable() %>% set_header_labels(values = c("type" = "Type", "subtype" = "Subtype", "rightITR" = "Right ITR", "count" = "Count")) }