[adegenet-forum] snpposi.plot with multiple chromosomes

Jombart, Thibaut t.jombart at imperial.ac.uk
Mon Aug 17 18:04:25 CEST 2015


Hi there, 

basically the workflow should be 1) split data by chromosome and 2) lapply over the result to generate the plot. 1) should be implemented by seploc, and I have just posted a feature request for this:
https://github.com/thibautjombart/adegenet/issues/84
and for the whole thing.

Meanwhile, there is a simple work around if you have i) SNP positions and ii) chromosome info. Split the first with the second, and apply snpposi.plot to the resulting list; or tapply directly. Here's an example with a simulated dataset:

## load package
library(adegenet)

## simulate data: 10 indiv, 1,000 SNPs from 10,000 nucleotide positions; first 600 SNPs are chr1, the other are chr2
x=glSim(10, 1000)
position(x) <- sort(sample(1:1e4, 1000))
chromosome(x) <- rep(1:2, c(600,400))

## split positions by chromosome and apply snpposi.plot to the bits
allPlots <- tapply(position(x), chromosome(x), snpposi.plot, genome.size=1e4)
allPlots[[1]] # chr 1
allPlots[[2]] # chr 2

Note that if you want the positions to be relative to the chromosomes, then you have to subtract manually the starting positions, e.g.
temp <- split(position(x), chromosome(x))
temp[[2]] <- temp[[2]] - 5504 # assuming chr 2 starts at position 5504
allPlots.scaled <- lapply(1:2, function(i) snpposi.plot(temp[[i]], genome.size=max(temp[[i]])))

Cheers
Thibaut




________________________________________
From: adegenet-forum-bounces at lists.r-forge.r-project.org [adegenet-forum-bounces at lists.r-forge.r-project.org] on behalf of Harriet Hunt [hvh22 at cam.ac.uk]
Sent: 17 August 2015 15:52
To: adegenet-forum at lists.r-forge.r-project.org
Subject: [adegenet-forum] snpposi.plot with multiple chromosomes

Hello all,

I have a dataset with SNP positions given as base numbers along
chromosomes, and the number of the chromosome is in a separate column in
the original data table. Can anyone suggest a way either to easily
select and plot the SNPs from one particular chromosome using
snpposi.plot, without having to extract the data for each chromosome
manually from the original data table? Or even better would be if
there's a way to use snpposi.plot to show the density plots for all the
chromosomes in order.

thanks, Harriet


_______________________________________________
adegenet-forum mailing list
adegenet-forum at lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum


More information about the adegenet-forum mailing list