This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Problem with snp function in R

Hello,

I've a big problem with snp function.

I must use it in first step of my analysis. If I use example of alleles (find -> https://www.rdocumentation.org/packages/SNPassoc/versions/2.0-11/topics/snp) everything is ok but if I use my data R give me error Error in snp(test, sep = "") : SNP must have only two alleles.

I check my data and it's the same class (character). Both datasets look the same.

test - my data

dat2 - example

I don't know what I've to do now... Please help. enter image description here

snpassoc snpfunction snp r gwas

1 answer

Read the documentation and understand your situation. For a biallelic diploid locus, there can only be 3 possible unphased configurations: HOM-REF, HET and HOM-ALT. Your "test" dataset has all 4 nucleotides, so obviously it's not a SNP at a single locus but a collection of SNPs - meaning, not all 10 configurations are possible at the same location.

Contrast this to dat2 where the only 2 alleles are A and G. Either change your dataset so it's compatible or use sapply(test, snp, sep = "") to get 10 SNP objects (not a meaningful thing to do)

Now, I understand, thanks :)

But I have one more question. It's my sample of individuals and I've got more than two alleles. For examples in E1 are C,G and A. What should I do with this problem? enter image description here

Did you try snp(vector_of_genotypes, sep = "")? That should work with E1, as long as it's a sensible vector. The E1 example is a diploid multi-allelic (not biallelic) locus (or a polyploid locus), so there are a lot more possibilities.

Yes, I tried and R shows me a error "SNP must have only two alleles"

Show me your exact code please.

Please do not paste screenshots of plain text content, it is counterproductive. You can copy paste the content directly here (using the code formatting option shown below), or use a GitHub Gist if the content volume exceeds allowed length here.

code_formatting

Oops, I did not see the E1 vector properly, just assumed it was sensible. Can you please explain how those genotypes can be found at the same site biologically? What is the REF allele and what are the various ALT alleles?

Log in to answer this question.