-
Notifications
You must be signed in to change notification settings - Fork 25
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
Colors in GWSS plots #591
Merged
Merged
Colors in GWSS plots #591
Changes from 43 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
699c1ab
Used the same kwargs method as in the CNV function
jonbrenas bfabef4
Merge branch 'master' into 583-GWSS-colors
leehart 2e8b4c4
Merge branch 'master' into 583-GWSS-colors
leehart 8db7a1c
Merge branch 'master' into 583-GWSS-colors
leehart e7e6b71
Color depending on contig. Still imperfect.
jonbrenas 787045a
Corrected wrong type.
jonbrenas 2ae87be
Corrected the doc.
jonbrenas 80ae2a4
Merge branch 'master' into 583-GWSS-colors
jonbrenas c3834bd
Something weird changed the test while they were being performed.
jonbrenas df0a0c5
Still a lot of weird stuff.
jonbrenas 52acfef
Still more weird stuff.
jonbrenas 212b164
Even more weird stuff.
jonbrenas bda3efe
The solution was obvious.
jonbrenas c63b572
Time for a detour.
jonbrenas 7fd9c4b
Uniformised the basic and user-provided option, somewhat.
jonbrenas 5a79a11
A bit of clean-up.
jonbrenas 87e27f2
Corrected a wrong type.
jonbrenas 948f86b
Added the wrong params file.
jonbrenas e49755f
Forgot to forward a change.
jonbrenas 9281b50
Merge branch 'master' into 583-GWSS-colors
jonbrenas 01ad5e3
Updated the tests a bit.
jonbrenas b2d9b0a
Dealt with h1x.
jonbrenas 20947b3
Gave the users more options.
jonbrenas 5f84b9d
Refining a type to defeat linting.
jonbrenas 90c5982
Same problem, different solution.
jonbrenas 528d3ec
Same problem, not s different solution.
jonbrenas fdef7eb
Same problem, not a solution.
jonbrenas f141953
Trying a new idea.
jonbrenas 2e34ff1
Going the opposite way.
jonbrenas ff54405
More tests.
jonbrenas f98d601
Simplified everything
jonbrenas 311f587
Changed sequence to list
jonbrenas 986004e
Fighting with len
jonbrenas 609c6a2
Merge branch 'master' into 583-GWSS-colors
jonbrenas bceb950
Corrected the merge
jonbrenas 48fb21e
Returned g123 to its normal state
jonbrenas 60780e1
Forgot 2 lines
jonbrenas e5da8a3
Merge branch 'master' into 583-GWSS-colors
jonbrenas d8e7e97
Merge branch 'master' into 583-GWSS-colors
jonbrenas 05a0fcc
Merged the _contig versions into the main versions
jonbrenas 7b08e61
Merge branch 'master' into 583-GWSS-colors
jonbrenas b25acb2
Added some examples in the notebook.
jonbrenas af6bac1
Merge branch 'master' into 583-GWSS-colors
jonbrenas 5a9c28a
Merge branch 'master' into 583-GWSS-colors
alimanfoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -84,8 +84,16 @@ def _h1x_gwss( | |||||
# Compute window midpoints. | ||||||
pos = ds1["variant_position"].values | ||||||
x = allel.moving_statistic(pos, statistic=np.mean, size=window_size) | ||||||
contigs = np.asarray( | ||||||
allel.moving_statistic( | ||||||
ds1["variant_contig"].values, | ||||||
statistic=np.median, | ||||||
size=window_size, | ||||||
), | ||||||
dtype=int, | ||||||
) | ||||||
|
||||||
results = dict(x=x, h1x=h1x) | ||||||
results = dict(x=x, h1x=h1x, contigs=contigs) | ||||||
|
||||||
return results | ||||||
|
||||||
|
@@ -98,6 +106,7 @@ def _h1x_gwss( | |||||
returns=dict( | ||||||
x="An array containing the window centre point genomic positions.", | ||||||
h1x="An array with H1X statistic values for each window.", | ||||||
contigs="An array with the contig for each window. The median is chosen for windows overlapping a change of contig.", | ||||||
), | ||||||
) | ||||||
def h1x_gwss( | ||||||
|
@@ -119,10 +128,10 @@ def h1x_gwss( | |||||
random_seed: base_params.random_seed = 42, | ||||||
chunks: base_params.chunks = base_params.native_chunks, | ||||||
inline_array: base_params.inline_array = base_params.inline_array_default, | ||||||
) -> Tuple[np.ndarray, np.ndarray]: | ||||||
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]: | ||||||
# Change this name if you ever change the behaviour of this function, to | ||||||
# invalidate any previously cached data. | ||||||
name = "h1x_gwss_v1" | ||||||
name = "h1x_gwss_contig_v1" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
params = dict( | ||||||
contig=contig, | ||||||
|
@@ -150,8 +159,9 @@ def h1x_gwss( | |||||
|
||||||
x = results["x"] | ||||||
h1x = results["h1x"] | ||||||
contigs = results["contigs"] | ||||||
|
||||||
return x, h1x | ||||||
return x, h1x, contigs | ||||||
|
||||||
@check_types | ||||||
@doc( | ||||||
|
@@ -181,14 +191,15 @@ def plot_h1x_gwss_track( | |||||
sizing_mode: gplt_params.sizing_mode = gplt_params.sizing_mode_default, | ||||||
width: gplt_params.width = gplt_params.width_default, | ||||||
height: gplt_params.height = 200, | ||||||
contig_colors: gplt_params.contig_colors = gplt_params.contig_colors_default, | ||||||
show: gplt_params.show = True, | ||||||
x_range: Optional[gplt_params.x_range] = None, | ||||||
output_backend: gplt_params.output_backend = gplt_params.output_backend_default, | ||||||
chunks: base_params.chunks = base_params.native_chunks, | ||||||
inline_array: base_params.inline_array = base_params.inline_array_default, | ||||||
) -> gplt_params.figure: | ||||||
# Compute H1X. | ||||||
x, h1x = self.h1x_gwss( | ||||||
x, h1x, contigs = self.h1x_gwss( | ||||||
contig=contig, | ||||||
analysis=analysis, | ||||||
window_size=window_size, | ||||||
|
@@ -240,15 +251,14 @@ def plot_h1x_gwss_track( | |||||
) | ||||||
|
||||||
# Plot H1X. | ||||||
fig.scatter( | ||||||
x=x, | ||||||
y=h1x, | ||||||
marker="circle", | ||||||
size=3, | ||||||
line_width=1, | ||||||
line_color="black", | ||||||
fill_color=None, | ||||||
) | ||||||
for s in set(contigs): | ||||||
idxs = contigs == s | ||||||
fig.scatter( | ||||||
x=x[idxs], | ||||||
y=h1x[idxs], | ||||||
marker="circle", | ||||||
color=contig_colors[s % len(contig_colors)], | ||||||
) | ||||||
|
||||||
# Tidy up the plot. | ||||||
fig.yaxis.axis_label = "H1X" | ||||||
|
@@ -289,6 +299,7 @@ def plot_h1x_gwss( | |||||
sizing_mode: gplt_params.sizing_mode = gplt_params.sizing_mode_default, | ||||||
width: gplt_params.width = gplt_params.width_default, | ||||||
track_height: gplt_params.track_height = 190, | ||||||
contig_colors: gplt_params.contig_colors = gplt_params.contig_colors_default, | ||||||
genes_height: gplt_params.genes_height = gplt_params.genes_height_default, | ||||||
show: gplt_params.show = True, | ||||||
output_backend: gplt_params.output_backend = gplt_params.output_backend_default, | ||||||
|
@@ -312,6 +323,7 @@ def plot_h1x_gwss( | |||||
sizing_mode=sizing_mode, | ||||||
width=width, | ||||||
height=track_height, | ||||||
contig_colors=contig_colors, | ||||||
show=False, | ||||||
output_backend=output_backend, | ||||||
chunks=chunks, | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nit, convention is to use the function name then add a version number.