Closed tathey1 closed 1 year ago
Hello @tathey1 ,
Your question could be about two different things, so I'll give short reply for each case. Please don't hesitate to specify further to continue the discussion.
You implemented a function and want to use it in your plots. In this case, with the function say test_function
written (in any file you want, or from another library, provided it has the correct API, you can create a myStatTest = StatTest(test_function, ...)
object with it, as we do for Wilcoxon on: https://github.com/trevismd/statannotations/blob/2a5ebe1a4d90c641552db580f3f285559e1bb277/statannotations/stats/StatTest.py#L125-L126
Then, you simply use annotator.configure(test=myStatTest)
to apply it. This doesn't require modifying the package's files.
Example with an external library function in a gist https://gist.github.com/trevismd/f556d83f6efdad249f995eb65daeb1d9.
This is explained in the code comments, and in some previous discussions, but it could have a spot on the README or usage notebook, and this contribution to the documentation would be very welcome! (as well as any other hole in the doc one wishes to fill).
You would like to share this method and make it part of statannotations
.
In this case, your understanding of the package's structure is correct and we should continue the discussion on the appropriateness of the change, because at some point I was wondering if an independent repository shouldn't exist for this kind of "extension".
Thanks for the response! My question was related to 1 - implementing my own test for myself. I didn't put two and two together and realize that I could feed in my own StatTest
object to Annotator.configure
. Now I have it working in the way you suggested.
I made a PR with both an addition to the notebook, and updates to the docs in case you want to proceed. For what it's worth the test I was adding is simply a log transform followed by a t-test (which is what I used in the example in the PR). Seems trivial to add to the core set of tests, but of course happy to do so if you like.
Thank you, @tathey1 !
Hi, thanks for the great package. What is the best convention for implementing new tests? I wrote a new test in the StatTest file, copying the wilcoxon example, however a new Annotator couldn't find the test, and raised an exception here. I (think I) got it to work by adding my new entry in
IMPLEMENTED_TESTS
in the test file, but I was not sure if this is the intended usage, since I couldn't find documentation directing me to do so.Happy to PR some documentation updates if you think it'd be useful.