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

error when flipping alleles and question about conversion to polar #5

Closed
kllrdr opened this issue Mar 24, 2022 · 3 comments
Closed
Labels
question Further information is requested

Comments

@kllrdr
Copy link

kllrdr commented Mar 24, 2022

Dear Joanna,

This is a wonderful software, thank you!

I am trying to flip the alleles and make one of the summary statistics as reference.
My sumstats are munged using LDSC, and look like this:
SNP A1 N Z A2
1 rs3094315 G 230059 -1.067 A
2 rs3131972 A 230636 -0.965 G

My code:
trait1 <- AlleleFlip(sumstats = trait1, snps = trait2 %>% select(SNP, A1, A2), snpid = "SNP", only.a2 = F)

I get the following error message:
Error in $<-.data.frame(*tmp*, "a1.b", value = character(0)) : replacement has 0 rows, data has 1217311

Can you help me troubleshoot it? I suppose that this is happening because of adding the Z-score column, what I already have in the data?

Also, in the tutorial when you are converting the data to polar (CES.AF <- ConvertToPolar(dfnames = traits, snpid = "snpid", whiten = T, LDcorrect = F), is it sufficient to define the traits as traits <- c("trait1", "trait2") before?

Thank you in advance for your help!
Dora

@Joannavonberg
Copy link
Collaborator

Hi Dora,

Thanks for the compliment! And thanks for raising an issue on Github. So you're getting a (not very clear) error message in R when you try to flip the alleles in trait1 to align them with the allele 'direction' in trait2. The first thing I notice when I look at your data (and thank you for including this, makes it much easier to help you) is that rownames are included in the data but not in the header. I suspect that what we might think is column "SNP" will actually give you the rownames (1, 2, ...) and the column called "A1" will give us the SNP rsids (rs3094315, rs3131972, ...). Is that correct? I don't know if that will solve all problems, but if this is the case we should at least get rid of the rownames. Let me know what happens if you change this!

@Joannavonberg Joannavonberg added the question Further information is requested label Mar 31, 2022
@Joannavonberg
Copy link
Collaborator

As for your question whether it's a problem to already have a z-score column in your dataframe / tibble: I suspect not, but the function will not change anything to your z-column. It actually expects there to be a "freq", "beta" and "se" column and changes these according to the flipped alleles. I do see the need for a new version of this function that can work without an allele frequency column (because PolarMorphism doesn't need it), and a version that can work with only z-scores if beta and se are not available. I'll think about adding this functionality, and I'll create a new issue for this

@kllrdr
Copy link
Author

kllrdr commented Apr 4, 2022

Hi Joanna,

Thank you so much for your answer!
I added beta, se and af columns to my dataset, and PolarMorphism run without an issue. You were right that the row numbers should have not been included, but it still did not run when the z score was present in the data.

But now it works properly, thanks for helping me investigate the issues!

@kllrdr kllrdr closed this as completed Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants