Coder Social home page Coder Social logo

Comments (4)

trevismd avatar trevismd commented on August 20, 2024

Hello @xinyuejohn , thank you for the question. Sorry this is yet poorly documented, and part 2 of the tutorial is long overdue...
(There is an example in the test suite:

def test_plot_and_annotate_facets(self):
annotator = Annotator(None, self.simple_pairs)
g = sns.FacetGrid(self.params_df.pop("data"),
col=self.params_df.pop("hue"),
height=10, sharey=False)
self.params_df.pop("hue_order")
g.map_dataframe(annotator.plot_and_annotate_facets,
plot="boxplot",
plot_params=self.params_df,
configuration={'test': 'Mann-Whitney',
'text_format': 'simple'},
annotation_func='apply_test',
ax_op_after=[['set_xlabel', ['Group'], None]],
annotation_params={'num_comparisons': 'auto'}
)
)

So basically should be using g.map_dataframe instead of g.map (this should really be in the docstring, I'm sorry), and thus provide the arguments directly to that function.

For your snippet, something like this:

annot = Annotator(None, pairs)
plot_and_annotate_facets = annot.plot_and_annotate_facets(
# deducing
plot_params = {
    'x': feature_name,
    'y': value_name
}  
g = sns.FacetGrid(
    data=plot_df,
    col="Cell type"
)
g.map_dataframe(
    annot.plot_and_annotate_facets,
    plot='boxplot', 
    plot_params=plot_params,
    configuration=configuration, 
    annotation_func='set_custom_annotations', 
    annotation_params=annotation_params, 
    **kwargs
)

Please let us know if something is still not working.

from statannotations.

xinyuejohn avatar xinyuejohn commented on August 20, 2024

Hello @xinyuejohn , thank you for the question. Sorry this is yet poorly documented, and part 2 of the tutorial is long overdue... (There is an example in the test suite:

def test_plot_and_annotate_facets(self):
annotator = Annotator(None, self.simple_pairs)
g = sns.FacetGrid(self.params_df.pop("data"),
col=self.params_df.pop("hue"),
height=10, sharey=False)
self.params_df.pop("hue_order")
g.map_dataframe(annotator.plot_and_annotate_facets,
plot="boxplot",
plot_params=self.params_df,
configuration={'test': 'Mann-Whitney',
'text_format': 'simple'},
annotation_func='apply_test',
ax_op_after=[['set_xlabel', ['Group'], None]],
annotation_params={'num_comparisons': 'auto'}
)

)
So basically should be using g.map_dataframe instead of g.map (this should really be in the docstring, I'm sorry), and thus provide the arguments directly to that function.

@trevismd Thank you so much for your reply! Your reply really helped a lot. But I still have some issue about pairs.

For example, in your test suite, you used self.simple_pairs as pairs. But if I want to only plot for some of the pairs ([(("a", "blue"), ("b", "blue"))]) instead of [["a", "b"]], I will get an error: Missing x value(s) "('a', 'blue')", "('b', 'blue')" in x (specified in pairs) in data

Could you please tell me if I can use such pairs when I plot? Thank you so much!

from statannotations.

hmassalha avatar hmassalha commented on August 20, 2024

hello @trevismd. you have here a great tool that a lot are interested in, however, it is not documented well. I find it a complete waste of time running between the different parts of codes/informations you gave for each comment trying hard to link them together. Would it be possible to provide a working example, from start to end, well documented, for adding annotations to catplot (grouped box plot output)? many thanks

from statannotations.

hmassalha avatar hmassalha commented on August 20, 2024

after 2h I managed to came over the following...
https://github.com/trevismd/statannotations/issues/36#issuecomment-1866210714
I still see a detailed doc will help with tweaking this amazing tool (e.g. between group stat rather than within group stat from catplot output, and more...)

from statannotations.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.