Skip to content

Commit

Permalink
Fix a minor issue with data writing
Browse files Browse the repository at this point in the history
  • Loading branch information
cansavvy committed Sep 30, 2024
1 parent f25c407 commit fa738ba
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions R/04-normalize.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,18 @@ gimap_normalize <- function(.data = NULL,
names_from = c(timepoints, replicates))


missing_ids <- setdiff(lfc_df$pg_ids, gimap_dataset$annotation$pgRNA_id)
missing_ids <- data.frame(
missing_ids = setdiff(lfc_df$pg_ids, gimap_dataset$annotation$pgRNA_id)
)

if ((length(missing_ids) > 0) & (length(missing_ids) < num_ids_wo_annot)){
message("The following ", length(missing_ids), " IDs were not found in the annotation data: \n", paste0(missing_ids, collapse = ", "))
if ((nrow(missing_ids) > 0) & (nrow(missing_ids) < num_ids_wo_annot)){
message("The following ", nrow(missing_ids), " IDs were not found in the annotation data: \n", paste0(missing_ids, collapse = ", "))
} else {
missing_ids_file <- file.path("missing_ids_file.csv")
readr::write_csv(missing_ids, missing_ids_file)
}

if ((length(missing_ids) > 0) & (rm_ids_wo_annot == TRUE)){
if ((nrow(missing_ids) > 0) & (rm_ids_wo_annot == TRUE)){
lfc_df <- lfc_df %>%
filter(!pg_ids %in% missing_ids)
message("The input data for the IDs which were not found in the annotation data has been filtered out and will not be included in the analysis output.")
Expand Down

0 comments on commit fa738ba

Please sign in to comment.