You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Extending getSegSiteGeno function to pull genotype instead of a list in multicolony setting #590
changed the title [-]Extending getWorkersSegSiteGeno function to pull genotype instead of a list in multicolony setting[/-][+]Extending getSegSiteGeno function to pull genotype instead of a list in multicolony setting[/+]on Dec 6, 2024
@DrMulusewFikere I am looking at this. So, the getSegSiteGeno() is designed such that we can work on a Pop object (say a group of individuals), a Colony (where we have multiple Pop slots), or a MultiColony (where we have multiple Colony "slots"). Here is example:
We get a list of genotype matrices. So, we should be able to just run getPooledGeno() on each of these:
> lapply(X = tmp, FUN = getPooledGeno)
Error in if (type == "mean") { : argument is of length zero
In addition: Warning message:
In FUN(X[[i]], ...) :
Argument sex is NULL. Assuming that all individuals are female/diploid!
Right, that's not what I expected! But, looking at the getPooledGeno() I see this will work (will improve the error message)
> str(lapply(X = tmp, FUN = getPooledGeno, type = "mean"))
List of 20
$ 1 : num [1, 1:30] 1.7632 0.0789 0.8947 0.2105 1.2368 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : NULL
.. ..$ : chr [1:30] "1_1" "1_2" "1_3" "1_4" ...
$ 2 : num [1, 1:30] 1.161 0.452 1.258 0.226 0.387 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : NULL
.. ..$ : chr [1:30] "1_1" "1_2" "1_3" "1_4" ...
So, we now have a list of one row matrices (with mean allele dosage of workers per colony) which we can rbind() using:
> tmpPooledGeno = lapply(X = tmp, FUN = getPooledGeno, type = "mean")
There were 20 warnings (use warnings() to see them)
> str(do.call(rbind, tmpPooledGeno))
num [1:20, 1:30] 1.763 1.161 0.618 0.941 1.833 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:30] "1_1" "1_2" "1_3" "1_4" ...
giving us a matrix with colonies in rows and markers in columns. Alternative would be:
> str(t(sapply(X = tmp, FUN = getPooledGeno, type = "mean")))
num [1:20, 1:30] 1.763 1.161 0.618 0.941 1.833 ...
- attr(*, "dimnames")=List of 2
..$ : chr [1:20] "1" "2" "3" "4" ...
..$ : NULL
There were 20 warnings (use warnings() to see them)
I appreciate this looks a bit involved, but it's because we work across colonies and we try to have a consistent way of working across Pop, Colony, and MultiColony, so it gets a bit involved, but not too much.
This will be a very common request, I think. So, we should probably add this to examples.
@DrMulusewFikere@janaobsteter I have changed the default to type = "mean and handle that argument better, and have also included the above into the examples section of getPooledGeno() as this will be much sought for thing. With this in mind I will change this into a discussion point.
Activity
[-]Extending getWorkersSegSiteGeno function to pull genotype instead of a list in multicolony setting[/-][+]Extending getSegSiteGeno function to pull genotype instead of a list in multicolony setting[/+]gregorgorjanc commentedon Dec 14, 2024
@DrMulusewFikere I am looking at this. So, the
getSegSiteGeno()is designed such that we can work on aPopobject (say a group of individuals), aColony(where we have multiplePopslots), or aMultiColony(where we have multipleColony"slots"). Here is example:giving
then
and finally
But, we did anticipate that people will want one block of genotypes, so we added the
collapseargument togetSegSiteGeno(). So, one could do:But I appreciate that you want to get pooled workers genotype per colony and the collapsed into a matrix across colonies!
So, how would we go about doing this in a clean way? Let's see what can already be done:
We get a list of genotype matrices. So, we should be able to just run
getPooledGeno()on each of these:Right, that's not what I expected! But, looking at the
getPooledGeno()I see this will work (will improve the error message)So, we now have a list of one row matrices (with mean allele dosage of workers per colony) which we can
rbind()using:giving us a matrix with colonies in rows and markers in columns. Alternative would be:
Does this help @DrMulusewFikere?
I appreciate this looks a bit involved, but it's because we work across colonies and we try to have a consistent way of working across
Pop,Colony, andMultiColony, so it gets a bit involved, but not too much.This will be a very common request, I think. So, we should probably add this to examples.
getPooledGeno(): Handle type arg, better default, and pooled example …
gregorgorjanc commentedon Dec 15, 2024
@DrMulusewFikere @janaobsteter I have changed the default to
type = "meanand handle that argument better, and have also included the above into the examples section ofgetPooledGeno()as this will be much sought for thing. With this in mind I will change this into a discussion point.