Skip to content
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

Unable to create effect size comparison plot without heterogeneity #112

Open
Sandyyy123 opened this issue Oct 24, 2024 · 6 comments
Open
Labels
bug Something isn't working enhancement New feature or request

Comments

@Sandyyy123
Copy link

Sandyyy123 commented Oct 24, 2024

I am unable to create effect size comparison plot without the need for conducting heteogeneity test and selective annotating/filtering.

Prepare kwargs for the comparison

kwargs = {
    "label": [label1, label2, "Both", "None"],
    "xylabel_prefix": "Per-allele effect size for ",
    "sig_level": 5e-8,
"anno": True,
    "is_q": False,
    "include_all": True,
    "drop": False,
    "is_q_mc": "fdr",  
    "save": os.path.join(base_path, plot_filename),
    "save_args": {"dpi": 300, "facecolor": "white"}
}

If I remove is_q_mc, I end up with error asking me to include it with bon or fdr option.

Also, I could not figure out how to include gene names instead of SNP ids. It seems the option is missing. It would rather require changing the SNPids directly to gene names.

@Cloufield
Copy link
Owner

Hi,
Thanks for the feedback.

If I remove is_q_mc, I end up with error asking me to include it with bon or fdr option.

I am wondering which gwaslab version you are using? In recent versions, this has been fixed.

Also, I could not figure out how to include gene names instead of SNP ids. It seems the option is missing. It would rather require changing the SNPids directly to gene names.

For this, I haven't added this to the effect size comparison plot yet. I will implement this in the new version and let you know (probably by the start of next week).

@Cloufield Cloufield added bug Something isn't working enhancement New feature or request labels Oct 25, 2024
@Sandyyy123
Copy link
Author

Hi Cloufield,
Thanks for getting back.
I updated to the latest package 3.4.49.
I am still getting the error:
raise ValueError("Please select either fdr or bon for is_q_mc.")
ValueError: Please select either fdr or bon for is_q_mc. Below is my command:

kwargs = {
"label": [label1, label2, "Both", "None"],
"xylabel_prefix": "Per-allele effect size for ",
"sig_level": 5e-8,
"anno": True,
"save": os.path.join(base_path, plot_filename),
"save_args": {"dpi": 300, "facecolor": "white"}
}

@Cloufield
Copy link
Owner

Hi,
sorry for my late reply.
I update gwaslab to v3.5.0. It now support annotation with GENENAME.
I tested with your setting and should work now.

kwargs = {
"label": ["label1", "label2", "Both", "None"],
"xylabel_prefix": "Per-allele effect size for ",
"sig_level": 5e-8,
"anno": "GENENAME",
"build":"19",
"save": True,
"save_args": {"dpi": 300, "facecolor": "white"}
}

image

Additionally, you can pass a SNPID:text dictionary for customized annotation like "anno": {"rs11642015":"Some customized annotation"},

image

@Sandyyy123
Copy link
Author

Sandyyy123 commented Nov 6, 2024 via email

@Sandyyy123
Copy link
Author

Sandyyy123 commented Nov 14, 2024

Hi,
I updated the gwaslab to the latest version available with pip install (3.5.0). I could not find 3.5.1 as per your logs for the updates. I was able to generate plots without heterogeneity. Thanks a lot.

However, it wasn't successful with anno="GENENAMES". I am getting no annotations using the command. I then tried to include build="19", i get an error: TypeError: compare_effect() got an unexpected keyword argument 'build'.

Prepare kwargs for the comparison

kwargs = {
    "label": [label1, label2, "Both", "None"],
    "xylabel_prefix": "Per-allele effect size for ",
    "r_se": True,
    "is_q": True,
    "is_q_mc": "fdr",
    "sig_level": 5e-8,
    "anno": "GENENAME",
    "build": "19",
    "anno_het": True,  # Always include this
    "legend_title": r'$ P < 5 x 10^{-8}$ in:',
    "verbose": True,
    "save": os.path.join(base_path, plot_filename),
    "save_args": {"dpi": 300, "facecolor": "white"}
}

I am also struggling with another issue of overlapping annotations, as two SNP names are completely overlapping. Is there a function like jitter in ggplot in your package?

Thanks

@Cloufield
Copy link
Owner

Hi,
Sorry for my late reply. I think the annotation function should work well using gwaslab v3.5.2.
For overlapping SNP names, I implemented a similar thing using a package called adjustText (https://adjusttext.readthedocs.io/en/latest/).
Unfortunately, it is not working well sometimes especially when the plot becomes complicated as you can see in the example plot (or maybe I haven't fully understood how this package works).
But You can try adjusting the args using adjust_text_kwargs_l for left side texts and adjust_text_kwargs_l for right side texts.
Or you can manually annotate those variants for now.
I will keep working on this and let you know when I solve this problem.

kwargs = {
"verbose":True,
"is_q":True,
"is_q_mc":"bon",
"label": ["label1", "label2", "Both", "None"],
"xylabel_prefix": "Per-allele effect size for ",
"sig_level": 6e-7,
"anno":"GENENAME",
"save": True,
 "wc_correction":"sig",
"anno_args":{"fontsize":15},
"font_args":{"fontsize":10},
"save_args": {"dpi": 300, "facecolor": "white"},
"adjust_text_kwargs_l":{"lim":2000,"expand_text":(3,3)},
"r_se":True
}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants