Skip to content

Small Issue - Hard Coded timepoint metadata in get_perturbation_effects() #18

@acmullen-med

Description

@acmullen-med

In get_perturbation_effects() on the output of fit_genotype_ccm() when passing interval_col = "timepointNumeric" I was getting a crash. When I renamed the colData(cds) to timepoint, remade ccs, remade ccm, it didn't crash.

Original

> testFitGenotypeCCM <- fit_genotype_ccm(genotype="Myod1Myf5", ccs=ccsPerturbV3Partition, interval_col="timepointNumeric", perturbation_col="perturbation",ctrl_ids=c("Control"),num_threads=25,num_bootstraps=10,penalize_by_distance = FALSE)
Fitting knockout model for Myod1Myf5
        time range: 11 to 48
        formula: ~  ns( timepointNumeric , knots= c(29.5) ) +  ns( timepointNumeric , knots= c(29.5) ):knockout + knockout
[1] "fitting model with 25 threads"
Warning message:
In Robject$getModel(var, index) :
  No such a model in the collection. Acceptable parameter values can be found via
$ranks (for PCA)
$clusters (for mixture models)
$penalties (for network)
Returning model with closest value. Requested: 0.000294161464618765 , returned: 0.00271708372175912
> perturb_effects <- platt::get_perturbation_effects(testFitGenotypeCCM,
  interval_col = "timepointNumeric",
  adjust_q_values = FALSE
)
Error in `mutate()`:
ℹ In argument: `genotype_eff = purrr::map(.f = make_contrast, .x = data, ccm = ccm, adjust_q_values = adjust_q_values)`.
Caused by error in `purrr::map()`:
ℹ In index: 1.
Caused by error in `mutate()`:
ℹ In argument: `timepoint_abund = purrr::map(...)`.
Caused by error in `purrr::map()`:
ℹ In index: 1.
Caused by error:
! object 'timepointNumeric' not found
Run `rlang::last_trace()` to see where the error occurred.
> 

Full Stack Trace for debugging.

> rlang::last_trace()
<error/dplyr:::mutate_error>
Error in `mutate()`:
ℹ In argument: `genotype_eff = purrr::map(.f = make_contrast, .x = data, ccm = ccm, adjust_q_values = adjust_q_values)`.
Caused by error in `purrr::map()`:
ℹ In index: 1.
Caused by error in `mutate()`:
ℹ In argument: `timepoint_abund = purrr::map(...)`.
---
Backtrace:
     ▆
  1. ├─platt::get_perturbation_effects(...)
  2. │ └─... %>% unnest(c(data, genotype_eff))
  3. ├─tidyr::unnest(., c(data, genotype_eff))
  4. ├─dplyr::mutate(...)
  5. ├─dplyr:::mutate.data.frame(...)
  6. │ └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
  7. │   ├─base::withCallingHandlers(...)
  8. │   └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
  9. │     └─mask$eval_all_mutate(quo)
 10. │       └─dplyr (local) eval()
 11. ├─purrr::map(.f = make_contrast, .x = data, ccm = ccm, adjust_q_values = adjust_q_values)
 12. │ └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
 13. │   ├─purrr:::with_indexed_errors(...)
 14. │   │ └─base::withCallingHandlers(...)
 15. │   ├─purrr:::call_with_cleanup(...)
 16. │   └─platt (local) .f(.x[[i]], ...)
 17. │     └─hooke::estimate_abundances(ccm, newdata = newdata_wt)
 18. │       └─... %>% tidyr::unnest(c(timepoint_abund))
 19. ├─tidyr::unnest(., c(timepoint_abund))
 20. ├─dplyr::select(., timepoint_abund)
 21. ├─dplyr::mutate(...)
 22. ├─dplyr:::mutate.data.frame(...)
 23. │ └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
 24. │   ├─base::withCallingHandlers(...)
 25. │   └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
 26. │     └─mask$eval_all_mutate(quo)
 27. │       └─dplyr (local) eval()
 28. ├─purrr::map(...)
 29. │ └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
 30. │   ├─purrr:::with_indexed_errors(...)
 31. │   │ └─base::withCallingHandlers(...)
 32. │   ├─purrr:::call_with_cleanup(...)
 33. │   └─hooke (local) .f(.x[[i]], ...)
 34. │     └─Matrix::sparse.model.matrix(model_terms, newdata, xlev = ccm@model_aux[["full_model_xlevels"]])
 35. │       ├─stats::model.frame(object, data, xlev = xlev)
 36. │       └─stats::model.frame.default(object, data, xlev = xlev)
 37. │         └─base::eval(predvars, data, env)
 38. │           └─base::eval(predvars, data, env)
 39. │             └─splines::ns(...)
 40. ├─base::.handleSimpleError(...)
 41. │ └─purrr (local) h(simpleError(msg, call))
 42. │   └─cli::cli_abort(...)
 43. │     └─rlang::abort(...)
 44. │       └─rlang:::signal_abort(cnd, .file)
 45. │         └─base::signalCondition(cnd)
 46. └─dplyr (local) `<fn>`(`<prrr_rr_>`)
---
Caused by error in `purrr::map()`:
ℹ In index: 1.
Caused by error:
! object 'timepointNumeric' not found
---
Backtrace:
     ▆
  1. ├─platt::get_perturbation_effects(...)
  2. │ └─... %>% unnest(c(data, genotype_eff))
  3. ├─tidyr::unnest(., c(data, genotype_eff))
  4. ├─dplyr::mutate(...)
  5. ├─dplyr:::mutate.data.frame(...)
  6. │ └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
  7. │   ├─base::withCallingHandlers(...)
  8. │   └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
  9. │     └─mask$eval_all_mutate(quo)
 10. │       └─dplyr (local) eval()
 11. ├─purrr::map(.f = make_contrast, .x = data, ccm = ccm, adjust_q_values = adjust_q_values)
 12. │ └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
 13. │   ├─purrr:::with_indexed_errors(...)
 14. │   │ └─base::withCallingHandlers(...)
 15. │   ├─purrr:::call_with_cleanup(...)
 16. │   └─platt (local) .f(.x[[i]], ...)
 17. │     └─hooke::estimate_abundances(ccm, newdata = newdata_wt)
 18. │       └─... %>% tidyr::unnest(c(timepoint_abund))
 19. ├─tidyr::unnest(., c(timepoint_abund))
 20. ├─dplyr::select(., timepoint_abund)
 21. ├─dplyr::mutate(...)
 22. ├─dplyr:::mutate.data.frame(...)
 23. │ └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
 24. │   ├─base::withCallingHandlers(...)
 25. │   └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
 26. │     └─mask$eval_all_mutate(quo)
 27. │       └─dplyr (local) eval()
 28. └─purrr::map(...)
 29.   └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
 30.     ├─purrr:::with_indexed_errors(...)
 31.     │ └─base::withCallingHandlers(...)
 32.     ├─purrr:::call_with_cleanup(...)
 33.     └─hooke (local) .f(.x[[i]], ...)
 34.       └─Matrix::sparse.model.matrix(model_terms, newdata, xlev = ccm@model_aux[["full_model_xlevels"]])
 35.         ├─stats::model.frame(object, data, xlev = xlev)
 36.         └─stats::model.frame.default(object, data, xlev = xlev)
 37.           └─base::eval(predvars, data, env)
 38.             └─base::eval(predvars, data, env)
 39.               └─splines::ns(...)

Change to
testFitGenotypeCCM <- fit_genotype_ccm(genotype="Myod1Myf5", ccs=ccsPerturbV3Partition, interval_col="timepoint", perturbation_col="perturbation",ctrl_ids=c("Control"),num_threads=25,num_bootstraps=10,penalize_by_distance = FALSE)

Confirming that the information in the colData is the same.

> dim(cdsPerturbV3rowDataSubset)
sum(cdsPerturbV3rowDataSubset$timepointNumeric == cdsPerturbV3rowDataSubset$timepoint)
[1]  30000 272738
[1] 272738

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions