Skip to content

Commit

Permalink
Add any to check for copy number data being in the form of a QDNAseqC…
Browse files Browse the repository at this point in the history
…opyNumbers object
  • Loading branch information
eldrid01 committed Jun 15, 2021
1 parent 409e1a7 commit 8c13c62
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions inst/scripts/fit_absolute_copy_numbers.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ library(rascal)
# function for extracting the copy number for a given sample
# can handle QDNAseqCopyNumbers object or a copy number data frame
copy_number_for_sample <- function(copy_number, sample) {
if (class(copy_number) == "QDNAseqCopyNumbers") {
if (any(class(copy_number) == "QDNAseqCopyNumbers")) {
copy_number <- copy_number[,sample]
copy_number_values <- Biobase::assayDataElement(copy_number, "copynumber")[,1]
segmented_values <- Biobase::assayDataElement(copy_number, "segmented")[,1]
Expand Down Expand Up @@ -88,7 +88,7 @@ if (any(class(copy_number) == "data.frame")) {
missing_columns <- setdiff(required_columns, colnames(copy_number))
if (length(missing_columns) > 0) stop("missing columns in", input_file, ": ", str_c(missing_columns, collapse = ", "))
samples <- sort(unique(copy_number$sample))
} else if (class(copy_number) == "QDNAseqCopyNumbers") {
} else if (any(class(copy_number) == "QDNAseqCopyNumbers")) {
if (!requireNamespace("QDNAseq", quietly = TRUE)) stop("QDNAseq package needs to be installed")
samples <- sort(Biobase::sampleNames(copy_number))
} else {
Expand Down
4 changes: 2 additions & 2 deletions inst/shiny/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ server <- function(input, output, session) {
samples <- sort(unique(copy_number_data$sample))
chromosomes <- levels(copy_number_data$chromosome)

} else if (class(copy_number_data) == "QDNAseqCopyNumbers") {
} else if (any(class(copy_number_data) == "QDNAseqCopyNumbers")) {
if (!requireNamespace(package = "QDNAseq", quietly = TRUE)) {
showModal(modalDialog(title = "Error", "The QDNAseq package needs to be installed in order to load a QDNAseqCopyNumbers object"))
return(NULL)
Expand Down Expand Up @@ -763,7 +763,7 @@ server <- function(input, output, session) {
selected_sample <- reactive_values$sample
if (is.null(selected_sample)) return(NULL)

if (class(copy_number_data) == "QDNAseqCopyNumbers") {
if (any(class(copy_number_data) == "QDNAseqCopyNumbers")) {
copy_number <- copy_number_data[,selected_sample]
copy_number_values <- Biobase::assayDataElement(copy_number, "copynumber")[,1]
segmented_values <- Biobase::assayDataElement(copy_number, "segmented")[,1]
Expand Down

0 comments on commit 8c13c62

Please sign in to comment.