Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Dendrogram class #274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 17 commits into from
Closed

Dendrogram class #274

wants to merge 17 commits into from

Conversation

merenlin
Copy link
Contributor

@merenlin merenlin commented Aug 4, 2015

Hi all, please have a look at the dendrogram wrapper and let me know if you want to add anything else at this point.
All feedback is welcome!

# Check that 2 is in a separate cluster
self.assertEqual(dendro.labels[0], '2')


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't require our users to have numpy or scipy installed to use this package. For this dendrogram class, it's OK to rely on these packages, you'll just have to make a few changes in this package organization to make this work:
1 - Move these tests into test_optional. That's the folder that we use for all the functionality that uses optional dependencies like numpy, matplotlib, scipy. Here is a file that you can place these tests into, instead: https://github.com/plotly/python-api/blob/master/plotly/tests/test_optional/test_opt_tracefactory.py
2 - Protect imports. More on that below!
We split our tests into two folders: test_core and test_optional. The only difference is that test_optional contains tests that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done with 3781906

@chriddyp
Copy link
Member

chriddyp commented Aug 4, 2015

Looks great, thanks for submitting! A few other comments besides those in the code:

  • We try to follow pep8 pretty closely so that all of our contributions look and read the same. Code editors usually have a pep8 style plug-in (I use sublime and this plug-in: https://github.com/dreadatour/Flake8Lint).
  • Thoughts on adding an option, or a separate FigureFactory, to include a heatmap and a second horizontal dendrogram?

@staticmethod
def create_dendrogram(X, orientation="bottom", labels=None,
colorscale=None, **kwargs):
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to keep the docstrings similar across the FigureFactory methods. I used this guideline https://github.com/plotly/dev-docs/blob/master/reference/styleguides/python.md#function-docstrings for the others.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cldougl seems like I can't access this link, but I tried to comply anyways =) have a look at 57e15bd

@merenlin
Copy link
Contributor Author

merenlin commented Aug 5, 2015

@chriddyp and @cldougl thanks! will fix/respond on each comment

as for

Thoughts on adding an option, or a separate FigureFactory, to include a heatmap and a second horizontal dendrogram?

You can already create a horizontal dendrogram using this class and adding them to a heatmap is not that difficult using subplots. Although an option of including dendrograms added to the existing heatmap function would come handy.


def __init__(self, X, orientation='bottom', labels=None, colorscale=None, \
width=700, height=700, xaxis='xaxis', yaxis='yaxis' ):
''' Draw a 2d dendrogram tree
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've been adding things like this with a BETA tag in the docstring. This way we don't have to promise backwards compatibility on these new wrappers. We simply use:

"""
Draw a 2d dendrogram tree.

BETA: May change without warning in a backwards-incompatible way.

...
"""

X: Heatmap matrix as array of arrays
orientation: 'top', 'right', 'bottom', or 'left'
labels: List of axis category labels
colorscale: Optional colorscale for dendrogram tree clusters
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐄 this is redundant, you've already added it with the :param: info beautifully above :)

@theengineear
Copy link
Contributor

Thanks for putting all this work in! There are still a couple things that could use some addressing. Mostly, I think adding more tests to lock down the expected functionality would do.

@theengineear theengineear mentioned this pull request Aug 24, 2015
@merenlin
Copy link
Contributor Author

merenlin commented Sep 4, 2015

@theengineear @cldougl Let's go for round 3 and perhaps you have some useful tips for improving orientation plots (see image in the comments above)

@theengineear
Copy link
Contributor

@OxanaSachenkova sorry for the radio silence! Let me know if you want me to pull down the branch to fix any conflicts! I'm happy to help with those.

@merenlin
Copy link
Contributor Author

@theengineear yes, I think it's better if you take over to fix the last things and resolve the conflicts. probably will be more efficient

@theengineear
Copy link
Contributor

Great, I'll do that today and we can get this in!

@theengineear
Copy link
Contributor

Closing this in favor of #312. Thanks @OxanaSachenkova !!!

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.

5 participants