hemstrow / snpR

GNU General Public License v3.0
26 stars 7 forks source link

plot_structure function with external admixture output #57

Open ssandovala opened 10 months ago

ssandovala commented 10 months ago

Hi Will,

I am trying to use the plot_structure function to plot outputs from admixture runs. I want to try to plot several K-values at once, and have population names in the X-axis, similar to your Mol. Ecol (2022) paper. However, I am having issues loading the inputs and defining the facets. First, the software only recognizes ".qopt" and not ".Q" as the input for Q matrices, so I renamed my files and created vectors with the population names to be used in the facet argument, one for each individual in my matrix and in the same order of the matrix. Then I defined the order of those populations with facet.order. However, I get an error and have not been able to make the plots, do you happen to know what is the issue? thanks!

Here is the code: plot_mod_dist <- plot_structure("females_thin_dist", facet = c("CA","CA","N_MX","N_MX","N_MX","AZ","AZ","AZ","AZ","AZ", "NM","NM","NM","MX","W_MX","W_MX","PA","PA","PA","PA", "PA","PA","PA","NY","NY","NY","NY","NY","NY","NY","NY", "NY","NY","TX","TX","TX","TX","TX","TX","TX","TX","TX", "TX","CO","CO","CO","CO","CO","TX","TX","TX","TX","TX", "TX","VA","VA","VA","VA","PA","PA","NJ","NJ","MO","MO", "SC","CT","CT","CT","CT","CT","PA","PA","PA","CA"), facet.order = c("CA","W_MX","AZ","NM","MX","N_MX","TX","CO","MO", "SC","VA","PA","NJ","CT","NY"), k = 2:5)

Here is the error: Error in names(x) <- value : 'names' attribute [8] must be the same length as the vector [1]

ssandovala commented 10 months ago

Adding to this because it worked now. Not sure why but it ran once I created objects for the vectors before defining the facets. Something like this:

pops <- c("CA","CA","N_MX","N_MX","N_MX","AZ","AZ","AZ","AZ","AZ", "NM","NM","NM","MX","W_MX","W_MX","PA","PA","PA","PA", "PA","PA","PA","NY","NY","NY","NY","NY","NY","NY","NY", "NY","NY","TX","TX","TX","TX","TX","TX","TX","TX","TX", "TX","CO","CO","CO","CO","CO","TX","TX","TX","TX","TX", "TX","VA","VA","VA","VA","PA","PA","NJ","NJ","MO","MO", "SC","CT","CT","CT","CT","CT","PA","PA","PA","CA")

order_pops <- c("CA","W_MX","AZ","NM","MX","N_MX","TX","CO","MO", "SC","VA","PA","NJ","CT","NY")

plot_mod_dist <- plot_structure("females_thin_dist", facet = pops, facet.order = order_pops, k = 2:5)

hemstrow commented 10 months ago

Hey Stephanie,

Huh, that's pretty weird! Would you feel comfortable sending me the data that you ran? A zipped file (. zip or.tar.gz) would work great. Seems like something I need to fix!

Thanks for the bug report, I really appreciate getting them!

Best, Will

On Thu, Dec 7, 2023, 1:40 PM Stephania Sandoval Arango < @.***> wrote:

Adding to this because it worked now. Not sure why but it ran once I created objects for the vectors before defining the facets. Something like this:

pops <- c("CA","CA","N_MX","N_MX","N_MX","AZ","AZ","AZ","AZ","AZ", "NM","NM","NM","MX","W_MX","W_MX","PA","PA","PA","PA", "PA","PA","PA","NY","NY","NY","NY","NY","NY","NY","NY", "NY","NY","TX","TX","TX","TX","TX","TX","TX","TX","TX", "TX","CO","CO","CO","CO","CO","TX","TX","TX","TX","TX", "TX","VA","VA","VA","VA","PA","PA","NJ","NJ","MO","MO", "SC","CT","CT","CT","CT","CT","PA","PA","PA","CA")

order_pops <- c("CA","W_MX","AZ","NM","MX","N_MX","TX","CO","MO", "SC","VA","PA","NJ","CT","NY")

plot_mod_dist <- plot_structure("females_thin_dist", facet = pops, facet.order = order_pops, k = 2:5)

— Reply to this email directly, view it on GitHub https://github.com/hemstrow/snpR/issues/57#issuecomment-1846152987, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHYMFP4RTHGVOZO5D22PHF3YIIZU7AVCNFSM6AAAAABALNKBPSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBWGE2TEOJYG4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>