-
Notifications
You must be signed in to change notification settings - Fork 22
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
ENH: Adding in invert option #83
Conversation
…ures with points/arrows
This looks good to me overall, although I would be interested to hear from @thermokarst, @nbokulich and @ebolyen on how we should proceed with this backwards incompatible change. Is there a preferred method to deprecate/change user-facing things like these? |
So we don't have a good mechanism to handle parameter deprecation (yet!). So avoiding that may be best for now. (FWIW, the rename here is incomplete as We also have an transpose action for feature tables now, so I think inverting samples/feature isn't the worst thing, but I totally get the motivation behind this rename, and in the future I am all for it. In the meanwhile having just |
Terms have been reverted, just the inversion option is added |
Hi @ElDeveloper @ebolyen is there anything outstanding on this? |
q2_emperor/_plot.py
Outdated
features = biplot.features.copy() | ||
samples = biplot.samples.copy() | ||
biplot.samples = features | ||
biplot.features = samples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of those Pythonic patterns that can be done like:
biplot.samples, biplot.features = biplot.features, biplot.samples
Let's wait to see if @ebolyen can have a look. |
q2_emperor/_plot.py
Outdated
biplot.samples = features | ||
biplot.features = samples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ElDeveloper like this?
biplot.samples = features | |
biplot.features = samples | |
biplot.features, biplot.samples = samples, features |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can even bypass the intermediate assignment to samples and features.
q2_emperor/_plot.py
Outdated
if invert: | ||
features = biplot.features.copy() | ||
samples = biplot.samples.copy() | ||
biplot.samples = features |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
biplot.samples = features | |
I'm not following. Could you elaborate?
GitHub just enabled suggested commits, which is pretty cool - you should be
able to suggest the exact line change.
…On Wed, Oct 2, 2019, 2:35 PM Yoshiki Vázquez Baeza ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In q2_emperor/_plot.py
<#83 (comment)>:
> number_of_features: int = 5) -> None:
+ if invert:
+ features = biplot.features.copy()
+ samples = biplot.samples.copy()
+ biplot.samples = features
+ biplot.features = samples
I think you can even bypass the intermediate assignment to samples and
features.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#83?email_source=notifications&email_token=AA75VXKAQZURDEZ5YNZQNADQMTSWFA5CNFSM4IPC46FKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCGVVTHI#discussion_r330706809>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA75VXOIAXLVMZHMVYYSZ4DQMTSWFANCNFSM4IPC46FA>
.
|
Hi Jamie,
I have tried the suggestions before, although you can't do multiline
comments, hence why I wasn't able to do that. My suggestion was to
change the code from:
+ if invert:
+ features = biplot.features.copy()
+ samples = biplot.samples.copy()
+ biplot.samples = features
+ biplot.features = samples
into:
+ if invert:
+ biplot.samples, biplot.features = biplot.features, biplot.samples
Does that make sense? Double assignments are a thing in python, and you
don't need intermediate variables. Alternatively, am I missing
something?
Thanks!
Yoshiki.
…On (Oct-02-19|18:42), Jamie Morton wrote:
I'm not following. Could you elaborate?
GitHub just enabled suggested commits, which is pretty cool - you should be
able to suggest the exact line change.
On Wed, Oct 2, 2019, 2:35 PM Yoshiki Vázquez Baeza ***@***.***>
wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In q2_emperor/_plot.py
> <#83 (comment)>:
>
> > number_of_features: int = 5) -> None:
>
> + if invert:
> + features = biplot.features.copy()
> + samples = biplot.samples.copy()
> + biplot.samples = features
> + biplot.features = samples
>
> I think you can even bypass the intermediate assignment to samples and
> features.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#83?email_source=notifications&email_token=AA75VXKAQZURDEZ5YNZQNADQMTSWFA5CNFSM4IPC46FKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCGVVTHI#discussion_r330706809>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AA75VXOIAXLVMZHMVYYSZ4DQMTSWFANCNFSM4IPC46FA>
> .
>
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#83 (comment)
|
Oh, got it. I have some suggested changes in the PR - so merge those in
when I'm back on the keyboard
On Wed, Oct 2, 2019, 2:48 PM Yoshiki Vázquez Baeza <notifications@github.com>
wrote:
… Hi Jamie,
I have tried the suggestions before, although you can't do multiline
comments, hence why I wasn't able to do that. My suggestion was to
change the code from:
+ if invert:
+ features = biplot.features.copy()
+ samples = biplot.samples.copy()
+ biplot.samples = features
+ biplot.features = samples
into:
+ if invert:
+ biplot.samples, biplot.features = biplot.features, biplot.samples
Does that make sense? Double assignments are a thing in python, and you
don't need intermediate variables. Alternatively, am I missing
something?
Thanks!
Yoshiki.
On (Oct-02-19|18:42), Jamie Morton wrote:
>I'm not following. Could you elaborate?
>GitHub just enabled suggested commits, which is pretty cool - you should
be
>able to suggest the exact line change.
>
>On Wed, Oct 2, 2019, 2:35 PM Yoshiki Vázquez Baeza <
***@***.***>
>wrote:
>
>> ***@***.**** commented on this pull request.
>> ------------------------------
>>
>> In q2_emperor/_plot.py
>> <#83 (comment)>:
>>
>> > number_of_features: int = 5) -> None:
>>
>> + if invert:
>> + features = biplot.features.copy()
>> + samples = biplot.samples.copy()
>> + biplot.samples = features
>> + biplot.features = samples
>>
>> I think you can even bypass the intermediate assignment to samples and
>> features.
>>
>> —
>> You are receiving this because you authored the thread.
>> Reply to this email directly, view it on GitHub
>> <
#83?email_source=notifications&email_token=AA75VXKAQZURDEZ5YNZQNADQMTSWFA5CNFSM4IPC46FKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCGVVTHI#discussion_r330706809
>,
>> or mute the thread
>> <
https://github.com/notifications/unsubscribe-auth/AA75VXOIAXLVMZHMVYYSZ4DQMTSWFANCNFSM4IPC46FA
>
>> .
>>
>
>
>--
>You are receiving this because you were mentioned.
>Reply to this email directly or view it on GitHub:
>#83 (comment)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#83?email_source=notifications&email_token=AA75VXL7TB4LXV7YRIUSUX3QMTUI3A5CNFSM4IPC46FKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAFZEBA#issuecomment-537629188>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA75VXOQ3AB7MJKFGFYCOATQMTUI3ANCNFSM4IPC46FA>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! Want me to push a commit with the assignment-swap?
Usability question: Right now, using the invert flag forces us to swap the sample and feature metadata inputs, which isn't quite what I was expecting when I was testing the assignment-swap. Should we assume the orientation is consistent between the ordination and the metadata and it's only the plot that is being inverted, or does the inversion change the semantics of the other parameters? I think arguments can be made both ways, but I kind of prefer just changing a single flag. |
@ebolyen thanks for bringing this up. The error is particularly confusing since it always refers to samples even if the mismatch is in features. In a recent PR I made a few changes to make this type dependent i.e. by feature or sample. See this PR: biocore/emperor#734 |
…rtonjt-term-swap
Hey all, I played with this in the new emperor just before last release to see if the situation was any different, but same deal as before. I think passing feature metadata to |
yea - the naming scheme is rather unfortunate; changing the names to something more abstract (i.e. points / arrows) would be preferable. @ebolyen what do you mean by flip the arrows / points internally? Would this nullify the use case for the invert option? |
Sorry I mean that the samples are always samples and features are always features, but when you set I think this makes more sense as now the arguments are always matched with their parameters, and you can just ask them to be drawn different from the default. |
@mortonjt @ElDeveloper, does that last commit seem like a reasonable way to do this? |
Pinging @mortonjt & @ElDeveloper (please see @ebolyen's request above) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me!
This PR accomplishes 2 things
This resolves the following issues
qiime2/q2-diversity#258
biocore/emperor#732
#82
See the following screenshot
CC @ElDeveloper @thermokarst @nbokulich