Skip to content

Robust handling of root-finding errors in fitpt.m0: skip genes with uniroot failures and return NA instead of stopping analysis - #35

Open
Ye1203 wants to merge 8 commits into
Winnie09:masterfrom
Ye1203:master
Open

Robust handling of root-finding errors in fitpt.m0: skip genes with uniroot failures and return NA instead of stopping analysis#35
Ye1203 wants to merge 8 commits into
Winnie09:masterfrom
Ye1203:master

Conversation

@Ye1203

@Ye1203 Ye1203 commented Jun 18, 2025

Copy link
Copy Markdown

When using fitpt.m0, some genes may cause an error in the uniroot call:

Error in uniroot(function(eta)): f() values at end points not of opposite sign,

because the interval endpoints have the same sign

(i.e., both digamma(1e-10 * meanN) - log(1e-10) + meanA and digamma(1e+10 * meanN) - log(1e+10) + meanA are positive or both negative).

In the original code, such errors would stop the entire lamian_test workflow, resulting in no output even for unaffected (normal) genes, and sometimes secondary errors like $ operator is invalid for atomic vectors.

In this patch, I modify fitpt.m0 to skip those problematic genes by returning NA when root-finding fails, and propagate this behavior so that corresponding entries are NA in the output from lamian_test. This ensures that analyses continue even if some genes cannot be fit, and all valid results for normal genes are still returned.

This change increases the robustness and fault-tolerance of the package, ensuring stable analysis even with problematic or edge-case data.

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

Successfully merging this pull request may close these issues.

1 participant