Skip to content

Commit

Permalink
Update loadContigs.R
Browse files Browse the repository at this point in the history
Prevent file.pattern from being NULL, causing all files in the directory to be read.
  • Loading branch information
Liripo authored Oct 15, 2024
1 parent e9d8f6d commit 5ed7311
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions R/loadContigs.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,19 @@ loadContigs <- function(input,
format = "10X") {
#Loading from directory, recursively
if (inherits(x=input, what ="character")) {
format.list <- list("WAT3R" = "barcode_results.csv",
"10X" = "filtered_contig_annotations.csv",
"AIRR" = "airr_rearrangement.tsv",
"Dandelion" = "all_contig_dandelion.tsv",
"Immcantation" = "_data.tsv",
"MiXCR" = "clones.tsv",
"JSON" = ".json",
"TRUST4" = "barcode_report.tsv",
"BD" = "Contigs_AIRR.tsv",
"Omniscope" =c("_OSB.csv", "_OST.csv"),
"ParseBio" = "barcode_report.tsv")
file.pattern <- format.list[[format]]
file.pattern <- switch(format,
"WAT3R" = "barcode_results.csv",
"10X" = "filtered_contig_annotations.csv",
"AIRR" = "airr_rearrangement.tsv",
"Dandelion" = "all_contig_dandelion.tsv",
"Immcantation" = "_data.tsv",
"MiXCR" = "clones.tsv",
"JSON" = ".json",
"TRUST4" = "barcode_report.tsv",
"BD" = "Contigs_AIRR.tsv",
"Omniscope" = c("_OSB.csv", "_OST.csv"),
"ParseBio" = "barcode_report.tsv",
stop("Invalid format: ",format))
contig.files <- list.files(input, paste0(file.pattern, collapse = "|"), recursive = TRUE, full.names = TRUE)

if (format %in% c("10X", "WAT3R", "Omniscope")) {
Expand Down Expand Up @@ -285,4 +286,4 @@ loadContigs <- function(input,
colnames(df[[i]]) <- c("barcode", "chain", "reads", "v_gene", "d_gene", "j_gene", "c_gene", "cdr3_nt", "cdr3", "productive")
}
return(df)
}
}

0 comments on commit 5ed7311

Please sign in to comment.