Question: ADMIXTURE and R, color meaning on barplot in studing population ancestry, K value
1
gravatar for dirranrak
2.6 years ago by
dirranrak10
United States
dirranrak10 wrote:

Hi all, I advanced using ADMIXTURE after using Plink and I have got K=5, so I ploted the data with R using col=5. I get the barplot with each bar representing an individual but how can I recognize the color label such as the red color for example and/or which population? because the *.5.Q file just has row or column for the proportions and each individual. Thank you.

R gene • 5.0k views
ADD COMMENTlink modified 7 days ago by edison.vazquez0 • written 2.6 years ago by dirranrak10
1

The key to generating the canonical admixture plots in R is to used a stacked barplot with the coancestry coefficients. Is this what you're doing? It's not clear.

ADD REPLYlink written 2.6 years ago by Brice Sarver2.4k

This is the plot from myfile.5.Q using R. I try to find what does mean each color (ancestry population probably? and if it is the case, which population?).

Here is the way I did it:

> tbl=read.table("trialmergedexcludedrs3926405,rs365066AfricaKhoisanexcludedsnpwith0phenotypegeno0.05hwe0.001Batwa_Kiga.913651pos.230samples.PNAS2014_trial1_flip.5.Q")
> barplot(t(as.matrix(tbl)), col=rainbow(5),
+ xlab="Individual", ylab="Ancestry", border=NA)

ADD REPLYlink written 2.6 years ago by dirranrak10

Hi, so the thing that I try to do with plink, admixture, and R is to find the ancestry(ies) of some populations in my genomic data.

I just got the proportions for each individual with ADMIXTURE and I ploted these files in R using K=2 to K=5. After that, the plot that I got are with different colors depending on K value, so the first one is with 2 colors and the last one is with 5 colors. the question is now, how can I Know the meaning of each color in each individual proportion?

Thank you so much.

 

ADD REPLYlink written 2.6 years ago by dirranrak10

Hello, did you find something?

Thank you.

ADD REPLYlink written 6 days ago by edison.vazquez0
1
gravatar for Zev.Kronenberg
2.6 years ago by
United States
Zev.Kronenberg11k wrote:

I just finished writing an set of functions for admixture plotting:

 

https://github.com/jewmanchue/ZevRTricks/blob/master/Addmixture2.plots.R

 

after sourcing the file point the R function at the directory containing the *.Q and *.fam

plots<-plot.admixture("/Users/zev/Documents/projects/human_diversity/admixture/")

to access subplot 5  :

plots$`5`
ADD COMMENTlink written 2.6 years ago by Zev.Kronenberg11k

@Zev.Kronenberg

I tried using the function but ran into following error (the last line). Is it something that i'm doing wrong?

plots<-plot.admixture("/my/directory/admixture_linux-1.3.0/")
Loading required package: reshape2
Loading required package: grid
Loading required package: ggplot2
Find out what's changed in ggplot2 at
http://github.com/hadley/ggplot2/releases.
Loading required package: plyr
Loading required package: RColorBrewer
Error in file(file, "rt") : invalid 'description' argument

 

ADD REPLYlink written 2.2 years ago by akang90

looks like the function is having trouble finding the files.  What are the file extensions? 

ADD REPLYlink written 2.2 years ago by Zev.Kronenberg11k

Standard output files of admixture plus a .fam file (Folder contains File.1.Q to File.10.Q & File.fam). Along with that the folder also has the results of admixture analysis of a different dataset. Could that be a problem? Is there a way to specify a particular inputfile?

ADD REPLYlink modified 2.2 years ago • written 2.2 years ago by akang90

Right now no. It should would if you separate the runs into different folders.  Feel free to change the [R] code to specify an input.  

ADD REPLYlink modified 2.2 years ago • written 2.2 years ago by Zev.Kronenberg11k

Thanks Zev! 

ADD REPLYlink written 2.2 years ago by akang90

I moved the results to a different directory and now i get this error: In levels<-(*tmp*, value = if (nl == nL) as.character(labels) else paste0(labels, : duplicated levels in factors are deprecated How to resolve this?

ADD REPLYlink written 2.1 years ago by akang90

Can you send me a test dataset?

ADD REPLYlink written 2.1 years ago by Zev.Kronenberg11k

@Zev,here is the test data

ADD REPLYlink modified 2.0 years ago • written 2.1 years ago by akang90

@Zev.Kronenberg The code worked once and but gives an error when I ran it the second time. I do not understand why.I tried plotting the same files, it ran fine once though

Error in data.frame(..., check.names = FALSE) : 
arguments imply differing number of rows: 0, 190
Error: with piece 1:
ADD REPLYlink modified 2.1 years ago • written 2.1 years ago by akang90

Hi Zev,

Thank you for the code. I was busy to understand learning coding other stuff. But now when I try to run your code in R, even just at the beginning I got the error below. And if I remove the quote when specifying the directory, the rest of the code becomes comment.

plot.admixture<-function("~/Documents/admixture_macosx-1.23") Error: unexpected string constant in "plot.admixture<-function('~/Documents/admixture_macosx-1.23'"

Do you have an idea why this happen?

ADD REPLYlink written 23 months ago by dirranrak10

Dear Zev, Thank you. I managed to get the admixture plot using your script. However, the x-axis has the individual samples names. Could it be possible to show the population group as well? the fam file looks the below way where the las column says the group.

`AC065 AC065 0 0 0 -9 G1
 AM236B1 AM236B1 0 0 0 -9 G1
 BB011 BB011 0 0 0 -9 G2
 BC1021 BC1021 0 0 0 -9 G3
 BC1026 BC1026 0 0 0 -9 G3`

The current script has the sample names from the second column on X-axis. Could it also include the group names to visualize both the sample names and the group to which it belongs to?

ADD REPLYlink modified 22 months ago • written 22 months ago by hellbio290
0
gravatar for edison.vazquez
7 days ago by
edison.vazquez0 wrote:

Dear Dirrank,

did you find the answer to your question?, because I'm in the same situation.

Thank you.

ADD COMMENTlink written 7 days ago by edison.vazquez0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1758 users visited in the last hour