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

Err during "Estimating sigma.." #209

Open
test12138jooh opened this issue Apr 22, 2024 · 25 comments
Open

Err during "Estimating sigma.." #209

test12138jooh opened this issue Apr 22, 2024 · 25 comments

Comments

@test12138jooh
Copy link

Dear professor,
I came across the problem when runing 10 trait, and the err log file was shown as below. I also tried to exlcude all variants containing "AGAAGA" genotype, it stiil gave the same erro output.
I will bed truly appreciated fot your help.

2024/04/22/10:36:59 PM Estimating sigma..
2024/04/22/10:37:09 PM 'AGAAGA'
Traceback (most recent call last):
  File "/local/StandTools/mtag/mtag.py", line 1577, in <module>
    mtag(args)
  File "/local/StandTools/mtag/mtag.py", line 1358, in mtag
    args.sigma_hat = estimate_sigma(DATA[not_SA], args)
  File "/local/StandTools/mtag/mtag.py", line 472, in estimate_sigma
    rg_results =  sumstats_sig.estimate_rg(args_ldsc_rg, Logger_to_Logging())
  File "/local/StandTools/mtag/ldsc_mod/ldscore/sumstats.py", line 442, in estimate_rg
    loop = _read_other_sumstats(args, log, None, sumstats, ref_ld_cnames,sumstats2=p2)
  File "/local/StandTools/mtag/ldsc_mod/ldscore/sumstats.py", line 494, in _read_other_sumstats
    loop['Z2'] = _align_alleles(loop.Z2, alleles)
  File "/local/StandTools/mtag/ldsc_mod/ldscore/sumstats.py", line 567, in _align_alleles
    z *= (-1) ** alleles.apply(lambda y: FLIP_ALLELES[y])
  File "/local/anaconda3/envs/zj/envs/mtag/lib/python2.7/site-packages/pandas/core/series.py", line 3591, in apply
    mapped = lib.map_infer(values, f, convert=convert_dtype)
  File "pandas/_libs/lib.pyx", line 2217, in pandas._libs.lib.map_infer
  File "/local/StandTools/mtag/ldsc_mod/ldscore/sumstats.py", line 567, in <lambda>
    z *= (-1) ** alleles.apply(lambda y: FLIP_ALLELES[y])
KeyError: 'AGAAGA'
2024/04/22/10:25:05 PM Analysis terminated from error at Mon Apr 22 22:25:05 2024
2024/04/22/10:25:05 PM Total time elapsed: 1.0m:11.41s

This is my command.

mtag.py \
--sumstats  tmp1.tsv,tmp2.tsv,tmp3.tsv \
--snp_name SNP \
--a1_name A1 \
--a2_name A2 \
--eaf_name MAF \
--z_name z_score \
--n_name NMISS \
--chr_name CHR \
--bpos_name BP \
--p_name P \
--maf_min 0 \
--n_min 0 \
--force \
--ld_ref_panel eas_ldscores_c/ \
--out mtag_result 

Thanks again.

Best,
JOOH

@test12138jooh test12138jooh changed the title Err in the Err during "Estimating sigma.." Apr 22, 2024
@JonJala
Copy link
Owner

JonJala commented Apr 22, 2024

Are you sure you filtered out all the "AGAAGA" SNPs? It looks like there are perhaps still some in your sample based on that error message.

@test12138jooh
Copy link
Author

Yeah; Thanks for your reply, But I wonder that does it mean MATG can only be applied to the SNV other than indel?

@paturley
Copy link
Collaborator

paturley commented Apr 23, 2024 via email

@test12138jooh
Copy link
Author

Thank you for your response! I've noticed that including only SNVs works well. Moreover, when utilizing the European reference panel, it effectively manages indels, unlike with other reference panels where it encounters failures. Is it possible that the reference panel itself is causing issues? Another concern is the SNP ID when using WGS data, as it's composed of chr:bp:ref:alt, with many not annotated by rsID.

@paturley
Copy link
Collaborator

paturley commented Apr 29, 2024 via email

@test12138jooh
Copy link
Author

test12138jooh commented Jun 13, 2024

Dear professor,
It seems that MTAG produces higher effect, How to explain it?Is it normal?
Attached is the log file.
Hope for your response. Thanks!

Change is great and seems unreliable.
type| beta | SE | P
raw_result | -0.01 | 0.01852 | 0.71
mtag | -0.0623 | 0.0136 | 4.58E-06

MTAG.log

@paturley
Copy link
Collaborator

Hi,

Is this just for a single SNP? MTAG results are based on standardized effects, so if you want a fair comparison, you need to compare the estimates after running MTAG on the single trait to the two-trait MTAG that you report above. Your log file looks mostly reasonable to me though.

@test12138jooh
Copy link
Author

test12138jooh commented Jun 13, 2024

Thanks for your reply. More specifically, I compared the raw results of SNP from GWAS summary data and the results of MTAG. I found the effect size of some snps have been greatly changed.How can this change be explained? Is this locus reliable? Are the effect sizes from MTAG trust worthy?
The snp I showed above :
In pheno1 GWAS summary data: beta=-0.01; SE=0.01852; P=0.71
In pheno2 GWAS summary data:beta=-0.024; SE=0.0035; P=4.30E-12
In MTAG result of pheno1: beta=-0.0623 ;SE=0.0136; P=4.58E-06

@paturley
Copy link
Collaborator

As I said, MTAG effect sizes are in standardized units. That is, it's the effect of a one-allele change in the SNP on the number of standard deviations of the phenotype. The original GWAS betas would just be in units of the original phenotype. I presume that the difference is due to that, but it could be a lot of other things too. Generally, for any meta-analysis-like procedure, some SNPs may change substantially just due to chance.

@test12138jooh
Copy link
Author

Thank you. But I have normlized the phenotype during GWAS analysis. So whether the beta in the MTAG analysis can be used for report?

@paturley
Copy link
Collaborator

I think you should be fine then.

@test12138jooh
Copy link
Author

Thank you again for your patience in answering my questions.

@test12138jooh
Copy link
Author

However,I noticed that some snps effect has also changed. Is it also Normal?Is there any soultions to these snp like heterogeneity test in meta analysis?
RAW phenotype1 GWAS summary:beta=-0.008;SE=0.02;P=0.622
RAW phenotype2 GWAS summary:beta=0.0173;SE=0.0031;P=1.99E-08
MTAG phenotype1 summary:beta=0.0222;SE=0.0046;P=1.79E-06

@paturley
Copy link
Collaborator

paturley commented Jun 13, 2024 via email

@test12138jooh
Copy link
Author

yes

@paturley
Copy link
Collaborator

paturley commented Jun 13, 2024 via email

@test12138jooh
Copy link
Author

test12138jooh commented Jun 13, 2024

So,does this mean that the mtag result was not informative enough when the snp did not reach the genome wide significant. I feel that the results of these SNPs are not very reliable.
Is it possible that the significantly larger sample size of my pheno2(N=160k) compared to pheno1(N=7K) caused this situation?

@paturley
Copy link
Collaborator

paturley commented Jun 13, 2024 via email

@test12138jooh
Copy link
Author

Thanks for your reply. It is true that the SNP is imprecise in GWAS (P-value=0.6). But how to define the imprecise SNP in MTAG; It still has a realtive low P value in MTAG (1.79E-06) while it did not reach the genome wide significant.

@paturley
Copy link
Collaborator

paturley commented Jun 13, 2024 via email

@test12138jooh
Copy link
Author

But another example:
RAW phenotype1 GWAS summary:beta=-0.0060;SE=0.01;P=0.665
RAW phenotype2 GWAS summary:beta=-0.024;SE=0.0025;P=4.73E-21
MTAG phenotype1 summary:beta=-0.035;SE=0.0041;P=1.35E-17

This snp are precisely estimated in MTAG but not GWAS and the beta has greatly changed.

@paturley
Copy link
Collaborator

paturley commented Jun 13, 2024 via email

@test12138jooh
Copy link
Author

So, can I consider the MTAG results reasonable as long as they fall within the confidence interval of the original results?

@paturley
Copy link
Collaborator

paturley commented Jun 13, 2024 via email

@test12138jooh
Copy link
Author

Thank you for your help.

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

No branches or pull requests

3 participants