Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Microarray] Issue combining dataframes using bind_rows() when getBM() returns no results #96

Open
cyouh95 opened this issue May 30, 2024 · 0 comments

Comments

@cyouh95
Copy link
Contributor

cyouh95 commented May 30, 2024

Description

The following error occurred when rendering Affymetrix.qmd for one dataset (but same issue could potentially arise in Agile1CMP.qmd too):

Error in `dplyr::bind_rows()`:
  ! Can't combine `..1$ensembl_gene_id` <logical> and `..2$ensembl_gene_id` <character>.

Error occurs when getBM() returns no rows, then ensembl_gene_id column is assumed to be logical type, causing the incompatibility in bind_rows().

df_mapping <- data.frame()
for (i in seq_along(probe_id_chunks)) {
probe_id_chunk <- probe_id_chunks[[i]]
print(glue::glue("Running biomart query chunk {i} of {length(probe_id_chunks)}. Total probes IDS in query ({length(probe_id_chunk)})"))
message(glue::glue("Running biomart query chunk {i} of {length(probe_id_chunks)}. Total probes IDS in query ({length(probe_id_chunk)})")) # NON_DPPD
chunk_results <- biomaRt::getBM(
attributes = c(
expected_attribute_name,
"ensembl_gene_id"
),
filters = expected_attribute_name,
values = probe_id_chunk,
mart = ensembl)
df_mapping <- df_mapping %>% dplyr::bind_rows(chunk_results)
Sys.sleep(10) # Slight break between requests to prevent back-to-back requests
}

Solution

Check if chunk_results contains any rows before binding to df_mapping in Affymetrix.qmd / Agile1CMP.qmd:

if (nrow(chunk_results) > 0) {
    df_mapping <- df_mapping %>% dplyr::bind_rows(chunk_results)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant