Skip to content

Commit

Permalink
exclude failed samples from annotation report
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyliu1326 committed Jun 20, 2023
1 parent a1f063d commit 1f5d24d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
17 changes: 8 additions & 9 deletions R/modules/annot/prepare_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ source(file.path(src_dir, "src/samnsero_summary.R"))
if (exists("amr_res_clean")) amr_drug_summary <- amr_class_sum(amr_res_clean)
if (!is_empty(annot_summary)) {
# create presence/absence matrix of each annotation type
tidy_res <- annot_sum2mat(annot_summary, var_only = F)
plasmid_summary <- getSummaryType(tidy_res, "Plasmid")
amr_summary <- getSummaryType(tidy_res, "AMR")
vf_summary <- getSummaryType(tidy_res, "Virulence Factor")
tidy_res <- annot_sum2mat(annot_summary, var_only = F) %>% select(sistr_res_clean$id)
plasmid_summary <- getSummaryType(tidy_res, "Plasmid") %>% select(sistr_res_clean$id)
amr_summary <- getSummaryType(tidy_res, "AMR") %>% select(sistr_res_clean$id)
vf_summary <- getSummaryType(tidy_res, "Virulence Factor") %>% select(sistr_res_clean$id)
# create presence/absence matrix of each annotation type (variable elements only)
tidy_res_var <- annot_sum2mat(annot_summary, var_only = T)
plasmid_summary_var <- getSummaryType(tidy_res_var, "Plasmid")
amr_summary_var <- getSummaryType(tidy_res_var, "AMR")
vf_summary_var <- getSummaryType(tidy_res_var, "Virulence Factor")

tidy_res_var <- annot_sum2mat(annot_summary, var_only = T) %>% select(sistr_res_clean$id)
plasmid_summary_var <- getSummaryType(tidy_res_var, "Plasmid") %>% select(sistr_res_clean$id)
amr_summary_var <- getSummaryType(tidy_res_var, "AMR") %>% select(sistr_res_clean$id)
vf_summary_var <- getSummaryType(tidy_res_var, "Virulence Factor") %>% select(sistr_res_clean$id)
}

2 changes: 1 addition & 1 deletion R/src/mob_suite_transpose.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ summary <- function(df) {
)
}) %>%
bind_rows() %>%
#mutate(id = factor(id, levels = samples)) %>%
mutate(id = factor(id, levels = samples)) %>%
pivot_wider(names_from = id,
values_from = value,
values_fill = ".",
Expand Down
2 changes: 1 addition & 1 deletion R/src/rgi_transpose.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ summary <- function(df) {
arrange(desc(Best_Identities)) %>%
slice(1) %>%
ungroup() %>%
mutate(#id = factor(id, levels = samples),
mutate(id = factor(id, levels = samples),
Best_Identities = as.character(Best_Identities)) %>%
pivot_wider(names_from = "id",
values_from = "Best_Identities",
Expand Down
1 change: 1 addition & 0 deletions R/src/samnsero_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ amr_class_sum <- function(df) {
pivot_wider(names_from = "id",
values_from = "n",
values_fill = 0,
values_fn = ~return(.[1]),
names_expand = T) %>%
column_to_rownames("Drug Class")
}
Expand Down

0 comments on commit 1f5d24d

Please sign in to comment.