-
Notifications
You must be signed in to change notification settings - Fork 8
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
fix annotation bug and make some beautifications #4
Open
JiaShun-Xiao
wants to merge
5
commits into
pgxcentre:master
Choose a base branch
from
JiaShun-Xiao:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -414,28 +414,32 @@ def create_manhattan_plot(twopoint, multipoint, args): | |
mec=args.significant_color) | ||
|
||
# If we want annotation | ||
count=0 | ||
if not args.no_annotation: | ||
for m_index, m in chrom_twopoint[sig_mask].iterrows(): | ||
chr_sig_snp = chrom_twopoint[sig_mask] | ||
chr_sig_snp = chr_sig_snp.sort_values(['conf'],ascending=False) | ||
for m_index, m in chr_sig_snp.iterrows(): | ||
# The confidence to write | ||
the_conf = "{:.3f}".format(m.conf) | ||
if args.use_pvalues_flag: | ||
the_conf = str(10 ** (-1 * m.conf)) | ||
|
||
# The label of the annotation | ||
label = "\n".join([m.snp, the_conf]) | ||
label = m.snp#"\n".join([m.snp, the_conf]) | ||
|
||
annot = ax.annotate( | ||
label, | ||
xy=(m.pos + starting_pos, m.conf), | ||
xycoords="data", | ||
size=10, | ||
xytext=(m.pos + starting_pos, conf_max), | ||
size=7, | ||
xytext=(m.pos + starting_pos+50000000, conf_max-count*0.33), | ||
va="center", | ||
bbox=dict(boxstyle="round", fc="white", ec="black"), | ||
bbox=dict(boxstyle="round", fc="white", alpha=0.4), | ||
textcoords="data", | ||
arrowprops=dict(arrowstyle="->", shrinkA=6, shrinkB=5), | ||
arrowprops=dict(arrowstyle="->",connectionstyle=mpl.patches.ConnectionStyle("Arc3, rad=0.15"),color='grey',alpha=0.6), | ||
) | ||
annots.append(annot) | ||
count +=1 | ||
|
||
# Changing the starting point for the next chromosome | ||
starting_pos = max_pos + starting_pos + chrom_spacing | ||
|
@@ -482,7 +486,12 @@ def create_manhattan_plot(twopoint, multipoint, args): | |
else: | ||
# There is some two-point data and annotation is asked, se we show | ||
# the figure | ||
plt.show() | ||
plt.savefig(args.outFile_name + "." + args.graph_format, | ||
bbox_inches="tight") | ||
if args.graph_format != "png": | ||
plt.savefig(args.outFile_name + ".png", bbox_inches="tight") | ||
if args.web: | ||
print(args.outFile_name + ".png") | ||
|
||
|
||
def encode_chr(chromosome): | ||
|
@@ -636,7 +645,7 @@ def parse_args(): | |
comma | ||
``--significant-threshold`` Float The significant threshold for | ||
linkage | ||
``--no-annotation`` Boolean Do not draw annotation (SNP names) | ||
``--no_annotation`` Boolean Do not draw annotation (SNP names) | ||
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. Please stay with previous options, so that it doesn't change existing scripts ( |
||
for the significant results | ||
``--chromosome-box-color`` String The *color* for the box surrounding | ||
even chromosome numbers | ||
|
@@ -893,7 +902,7 @@ def parse_args(): | |
|
||
# The annotation flag | ||
group.add_argument( | ||
"--no-annotation", action="store_true", | ||
"--no_annotation", action="store_true", | ||
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. Same thing here, keep |
||
help="Do not draw annotation (SNP names) for the significant results.", | ||
) | ||
|
||
|
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.
This else is now irrelevant, since the same code is executed in both cases.