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

Add optional constraints to win.ia and samp.ia by chromosome #117

Closed
zkamvar opened this issue Oct 18, 2016 · 1 comment
Closed

Add optional constraints to win.ia and samp.ia by chromosome #117

zkamvar opened this issue Oct 18, 2016 · 1 comment
Assignees
Milestone

Comments

@zkamvar
Copy link
Member

zkamvar commented Oct 18, 2016

Currently, samp.ia and win.ia don't take into account chromosome. This is especially important for win.ia because the positions might be relative to chromosome, screwing up the windowing. The process should be:

  1. detect if there is positional data
  2. detect if there is chromosomal data
  3. detect if the positions are relative to chromosome
  4. reassign positions if 3 is true.

Here's some example code assuming x is a genlight object:

if (is.null(position(x))){
  position(x) <- seq(nLoc(x))
}
pos <- position(x)
if (!is.null(chromosome(x))){
  # Each chromosome has it's own position.
  # In this case, get large round number for each chromosome break.
  maxp <- 10^ceiling(log(max(pos), 10))
  if (length(unique(pmin(pos))) < nLoc(x)){
    pos <- split(pos, chromosome(x))
    for (p in seq(pos)){
      if (p != 1){
        pos[[p]] <- pos[[p]] + (maxp*(p - 1))
      }
    }
    pos <- unlist(pos, use.names = FALSE)
  }
}

This will set up the positions for windowing.

@zkamvar zkamvar self-assigned this Oct 18, 2016
@zkamvar zkamvar added this to the poppr 2.4 milestone Nov 21, 2016
zkamvar added a commit that referenced this issue Dec 21, 2016
This will address #117.

Briefly, this update allows win.ia to parameterize
the window based on chromosome coordinates. It
solves an issue that appears when positions are
specified relative to the chromosome where the
positions are taken together and incorrectly
summarized.
@zkamvar zkamvar modified the milestones: poppr 2.4.1, poppr 2.4 Apr 10, 2017
@zkamvar
Copy link
Member Author

zkamvar commented Apr 13, 2017

Since samp.ia() doesn't care about position, this issue might be a bit moot for it. Given that, I'm declaring this as done since Saturnalia, 2016.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant