Closed hpages closed 3 years ago
I like the explicit error messages that tell the users what they need to do, and agree that this is useful regardless if there is an umbrella package that loads MatrixGenerics
, DelayedMatrixStats
and sparseMatrixStats
.
I'll try to come up with a full patch next week.
Agreed, this looks useful.
Hi @const-ae, @PeteHaitch, @LTLA, @lawremi,
This improves a little bit upon my earlier proposal on the community-bioc slack this morning (bigdata-rep channel) of loading all the suggested packages the first time a MatrixGenerics' generic is called (e.g. the first time
MatrixGenerics::colVars()
is called). With this new approach, if I'm passing a dgCMatrix object and if sparseMatrixStats is already loaded, the fallback mechanism won't try to load anything. So this addresses Nicholas Knoblauch's concern that there is no reason to throw an error that DelayedMatrixStats is not installed in that case.Without fallback mechanism:
With the fallback mechanism:
If sparseMatrixStats is installed, the fallback mechanism loads it so dispatch can find the method:
If sparseMatrixStats and "other suggested packages to search" (e.g. DelayedMatrixstats) are not installed we get:
If sparseMatrixStats is the only "other suggested packages to search" that is not installed we get:
Note that this approach still doesn't guarantee that users will always have all the packages that define every possible methods for the MatrixGenerics' generics, so is complementary to Aaron's approach of using beachmat or scuttle as an umbrella package for the sc-stack that he controls. But at least it provides a reasonable safety net for packages that don't belong to this stack. They need to import MatrixGenerics only.
Open for discussion.
H.