https://mcfromnz.wordpress.com/2012/11/06/forest-plots-in-r-ggplot-with-side-table/#more-356
2013年7月28日星期日
driftsel: an R package for detecting signals of natural selection in quantitative traits
http://onlinelibrary.wiley.com/doi/10.1111/1755-0998.12111/full
Approaches and tools to differentiate between natural selection and genetic drift as causes of population differentiation are of frequent demand in evolutionary biology. Based on the approach of Ovaskainen et al. (2011), we have developed an R package (driftsel) that can be used to differentiate between stabilizing selection, diversifying selection and random genetic drift as causes of population differentiation in quantitative traits when neutral marker and quantitative genetic data are available. Apart from illustrating the use of this method and the interpretation of results using simulated data, we apply the package on data from three-spined sticklebacks (Gasterosteus aculeatus) to highlight its virtues. driftsel can also be used to perform usual quantitative genetic analyses in common-garden study designs.
Approaches and tools to differentiate between natural selection and genetic drift as causes of population differentiation are of frequent demand in evolutionary biology. Based on the approach of Ovaskainen et al. (2011), we have developed an R package (driftsel) that can be used to differentiate between stabilizing selection, diversifying selection and random genetic drift as causes of population differentiation in quantitative traits when neutral marker and quantitative genetic data are available. Apart from illustrating the use of this method and the interpretation of results using simulated data, we apply the package on data from three-spined sticklebacks (Gasterosteus aculeatus) to highlight its virtues. driftsel can also be used to perform usual quantitative genetic analyses in common-garden study designs.
2013年7月18日星期四
2013年7月12日星期五
choose colors for your plots
1. The HTML 4.01 specification[9] defines sixteen named colors, as follows (names are defined in this context to be case-insensitive):
http://en.wikipedia.org/wiki/Web_colors
2. using colors in R
http://en.wikipedia.org/wiki/Web_colors
| Color | Name | Hex (RGB) | Red (RGB) | Green (RGB) | Blue (RGB) | Hue (HSL/HSV) | Satur (HSL) | Light (HSL) | Satur (HSV) | Value (HSV) | CGA number (name); alias |
|---|---|---|---|---|---|---|---|---|---|---|---|
| White | #FFFFFF | 100% | 100% | 100% | 0° | 0% | 100% | 0% | 100% | 15 (white) | |
| Silver | #C0C0C0 | 75% | 75% | 75% | 0° | 0% | 75% | 0% | 75% | 7 (light gray) | |
| Gray | #808080 | 50% | 50% | 50% | 0° | 0% | 50% | 0% | 50% | 8 (dark gray) | |
| Black | #000000 | 0% | 0% | 0% | 0° | 0% | 0% | 0% | 0% | 0 (black) | |
| Red | #FF0000 | 100% | 0% | 0% | 0° | 100% | 50% | 100% | 100% | 12 (high red) | |
| Maroon | #800000 | 50% | 0% | 0% | 0° | 100% | 25% | 100% | 50% | 4 (low red) | |
| Yellow | #FFFF00 | 100% | 100% | 0% | 60° | 100% | 50% | 100% | 100% | 14 (yellow) | |
| Olive | #808000 | 50% | 50% | 0% | 60° | 100% | 25% | 100% | 50% | 6 (brown) | |
| Lime | #00FF00 | 0% | 100% | 0% | 120° | 100% | 50% | 100% | 100% | 10 (high green); green | |
| Green | #008000 | 0% | 50% | 0% | 120° | 100% | 25% | 100% | 50% | 2 (low green) | |
| Aqua | #00FFFF | 0% | 100% | 100% | 180° | 100% | 50% | 100% | 100% | 11 (high cyan); cyan | |
| Teal | #008080 | 0% | 50% | 50% | 180° | 100% | 25% | 100% | 50% | 3 (low cyan) | |
| Blue | #0000FF | 0% | 0% | 100% | 240° | 100% | 50% | 100% | 100% | 9 (high blue) | |
| Navy | #000080 | 0% | 0% | 50% | 240° | 100% | 25% | 100% | 50% | 1 (low blue) | |
| Fuchsia | #FF00FF | 100% | 0% | 100% | 300° | 100% | 50% | 100% | 100% | 13 (high magenta); magenta | |
| Purple | #800080 | 50% | 0% | 50% | 300° | 100% | 25% | 100% | 50% | 5 (low magenta) |
http://research.stowers-institute.org/efg/Report/UsingColorInR.pdf
| interior | font | HTML | bgcolor= | Red< | Green | Blue | Color |
| Black | [Color 1] | #000000 | #000000 | 0 | 0 | 0 | [Black] |
| White | [Color 2] | #FFFFFF | #FFFFFF | 255 | 255 | 255 | [White] |
| Red | [Color 3] | #FF0000 | #FF0000 | 255 | 0 | 0 | [Red] |
| Green | [Color 4] | #00FF00 | #00FF00 | 0 | 255 | 0 | [Green] |
| Blue | [Color 5] | #0000FF | #0000FF | 0 | 0 | 255 | [Blue] |
| Yellow | [Color 6] | #FFFF00 | #FFFF00 | 255 | 255 | 0 | [Yellow] |
| Magenta | [Color 7] | #FF00FF | #FF00FF | 255 | 0 | 255 | [Magenta] |
| Cyan | [Color 8] | #00FFFF | #00FFFF | 0 | 255 | 255 | [Cyan] |
| [Color 9] | [Color 9] | #800000 | #800000 | 128 | 0 | 0 | [Color 9] |
| [Color 10] | [Color 10] | #008000 | #008000 | 0 | 128 | 0 | [Color 10] |
| [Color 11] | [Color 11] | #000080 | #000080 | 0 | 0 | 128 | [Color 11] |
| [Color 12] | [Color 12] | #808000 | #808000 | 128 | 128 | 0 | [Color 12] |
| [Color 13] | [Color 13] | #800080 | #800080 | 128 | 0 | 128 | [Color 13] |
| [Color 14] | [Color 14] | #008080 | #008080 | 0 | 128 | 128 | [Color 14] |
| [Color 15] | [Color 15] | #C0C0C0 | #C0C0C0 | 192 | 192 | 192 | [Color 15] |
| [Color 16] | [Color 16] | #808080 | #808080 | 128 | 128 | 128 | [Color 16] |
| [Color 17] | [Color 17] | #9999FF | #9999FF | 153 | 153 | 255 | [Color 17] |
| [Color 18] | [Color 18] | #993366 | #993366 | 153 | 51 | 102 | [Color 18] |
| [Color 19] | [Color 19] | #FFFFCC | #FFFFCC | 255 | 255 | 204 | [Color 19] |
| [Color 20] | [Color 20] | #CCFFFF | #CCFFFF | 204 | 255 | 255 | [Color 20] |
| [Color 21] | [Color 21] | #660066 | #660066 | 102 | 0 | 102 | [Color 21] |
| [Color 22] | [Color 22] | #FF8080 | #FF8080 | 255 | 128 | 128 | [Color 22] |
| [Color 23] | [Color 23] | #0066CC | #0066CC | 0 | 102 | 204 | [Color 23] |
| [Color 24] | [Color 24] | #CCCCFF | #CCCCFF | 204 | 204 | 255 | [Color 24] |
| [Color 25] | [Color 25] | #000080 | #000080 | 0 | 0 | 128 | [Color 25] |
| [Color 26] | [Color 26] | #FF00FF | #FF00FF | 255 | 0 | 255 | [Color 26] |
| [Color 27] | [Color 27] | #FFFF00 | #FFFF00 | 255 | 255 | 0 | [Color 27] |
| [Color 28] | [Color 28] | #00FFFF | #00FFFF | 0 | 255 | 255 | [Color 28] |
| [Color 29] | [Color 29] | #800080 | #800080 | 128 | 0 | 128 | [Color 29] |
| [Color 30] | [Color 30] | #800000 | #800000 | 128 | 0 | 0 | [Color 30] |
| [Color 31] | [Color 31] | #008080 | #008080 | 0 | 128 | 128 | [Color 31] |
| [Color 32] | [Color 32] | #0000FF | #0000FF | 0 | 0 | 255 | [Color 32] |
| [Color 33] | [Color 33] | #00CCFF | #00CCFF | 0 | 204 | 255 | [Color 33] |
| [Color 34] | [Color 34] | #CCFFFF | #CCFFFF | 204 | 255 | 255 | [Color 34] |
| [Color 35] | [Color 35] | #CCFFCC | #CCFFCC | 204 | 255 | 204 | [Color 35] |
| [Color 36] | [Color 36] | #FFFF99 | #FFFF99 | 255 | 255 | 153 | [Color 36] |
| [Color 37] | [Color 37] | #99CCFF | #99CCFF | 153 | 204 | 255 | [Color 37] |
| [Color 38] | [Color 38] | #FF99CC | #FF99CC | 255 | 153 | 204 | [Color 38] |
| [Color 39] | [Color 39] | #CC99FF | #CC99FF | 204 | 153 | 255 | [Color 39] |
| [Color 40] | [Color 40] | #FFCC99 | #FFCC99 | 255 | 204 | 153 | [Color 40] |
| [Color 41] | [Color 41] | #3366FF | #3366FF | 51 | 102 | 255 | [Color 41] |
| [Color 42] | [Color 42] | #33CCCC | #33CCCC | 51 | 204 | 204 | [Color 42] |
| [Color 43] | [Color 43] | #99CC00 | #99CC00 | 153 | 204 | 0 | [Color 43] |
| [Color 44] | [Color 44] | #FFCC00 | #FFCC00 | 255 | 204 | 0 | [Color 44] |
| [Color 45] | [Color 45] | #FF9900 | #FF9900 | 255 | 153 | 0 | [Color 45] |
| [Color 46] | [Color 46] | #FF6600 | #FF6600 | 255 | 102 | 0 | [Color 46] |
| [Color 47] | [Color 47] | #666699 | #666699 | 102 | 102 | 153 | [Color 47] |
| [Color 48] | [Color 48] | #969696 | #969696 | 150 | 150 | 150 | [Color 48] |
| [Color 49] | [Color 49] | #003366 | #003366 | 0 | 51 | 102 | [Color 49] |
| [Color 50] | [Color 50] | #339966 | #339966 | 51 | 153 | 102 | [Color 50] |
| [Color 51] | [Color 51] | #003300 | #003300 | 0 | 51 | 0 | [Color 51] |
| [Color 52] | [Color 52] | #333300 | #333300 | 51 | 51 | 0 | [Color 52] |
| [Color 53] | [Color 53] | #993300 | #993300 | 153 | 51 | 0 | [Color 53] |
| [Color 54] | [Color 54] | #993366 | #993366 | 153 | 51 | 102 | [Color 54] |
| [Color 55] | [Color 55] | #333399 | #333399 | 51 | 51 | 153 | [Color 55] |
| [Color 56] | [Color 56] | #333333 | #333333 | 51 | 51 | 51 | [Color 56] |
| Excel only recognizes names for Color 1 through 8 (Black, White, Red, Green, Blue, Yellow, Magenta, and Cyan). The colors 1-16 are widely understood color names from the VGA color palette. Of the 56 colors only 40 colors appear on the palette. The 40 colors names indicated on the Excel color palette (see below) are for descriptive purposes only. | |||||||
2013年7月2日星期二
parsing arguements in a R script
http://ggorjan.blogspot.ca/2013/07/parse-arguments-of-r-script.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+GregorGorjancsBlog+(Gregor+Gorjanc's+blog)
R can be used also as a scripting tool. We just need to add shebang in the first line of a file (script):
#!/usr/bin/Rscript
and then the R code should follow.
(TRUE)
## Default setting when no arguments passed
if(length(args) < 1) {
args <- a="" href="http://inside-r.org/r-doc/base/c" style="color: #b81909; text-decoration: none;">c->("--help")
}
## Help section
if("--help" %in% args) {
cat("
The R Script
Arguments:
--arg1=someValue - numeric, blah blah
--arg2=someValue - character, blah blah
--arg3=someValue - logical, blah blah
--help - print this text
Example:
./test.R --arg1=1 --arg2="output.txt" --arg3=TRUE \n\n")
q(save="no")
}
## Parse arguments (we expect the form --arg=value)
parseArgs <- a="" href="http://inside-r.org/r-doc/base/function" style="color: #b81909; text-decoration: none;">function->(x) strsplit(sub("^--", "", x), "=")
argsDF <- a="" href="http://inside-r.org/r-doc/base/as.data.frame" style="color: #b81909; text-decoration: none;">as.data.frame->(do.call("rbind", parseArgs(args)))
argsL <- a="" href="http://inside-r.org/r-doc/base/as.list" style="color: #b81909; text-decoration: none;">as.list->(as.character(argsDF$V2))
names(argsL) <- argsdf="" nbsp="" span="" style="font-style: italic;">## Arg1 default->
if(is.null(args$arg1)) {
## do something
}
## Arg2 default
if(is.null(args$arg2)) {
## do something
}
## Arg3 default
if(is.null(args$arg3)) {
## do something
}
It is some work, but I find it pretty neat and use it for quite a while now. I do wonder what others have come up for this task. I hope I did not miss some very general solution.
R can be used also as a scripting tool. We just need to add shebang in the first line of a file (script):
#!/usr/bin/Rscript
and then the R code should follow.
Often we want to pass arguments to such a script, which can be collected in the script by the commandArgs() function. Then we need to parse the arguments and conditional on them do something. I came with a rather general way of parsing these arguments using simply these few lines:
## Collect arguments args <- a="" href="http://inside-r.org/r-doc/base/commandArgs" style="color: #b81909; text-decoration: none;">commandArgs->
## ... your code here ...
Created by Pretty R at inside-R.orgIt is some work, but I find it pretty neat and use it for quite a while now. I do wonder what others have come up for this task. I hope I did not miss some very general solution.
2013年6月27日星期四
distinguish effects of geographic and ecological isolation on differentiation
Populations can be genetically isolated by both geographic distance and by differences in their ecology or environment that decrease the rate of successful migration. Empirical studies often seek to investigate the relationship between genetic differentiation and some ecological variable(s) while accounting for geographic distance, but common approaches to this problem (such as the partial Mantel test) have a number of drawbacks. In this article, we present a Bayesian method that enables users to quantify the relative contributions of geographic distance and ecological distance to genetic differentiation between sampled populations or individuals. We model the allele frequencies in a set of populations at a set of unlinked loci as spatially correlated Gaussian processes, in which the covariance structure is a decreasing function of both geographic and ecological distance. Parameters of the model are estimated using a Markov chain Monte Carlo algorithm. We call this method Bayesian Estimation of Differentiation in Alleles by Spatial Structure and Local Ecology (BEDASSLE), and have implemented it in a user-friendly format in the statistical platform R. We demonstrate its utility with a simulation study and empirical applications to human and teosinte datasets.
http://arxiv.org/abs/1302.3274
http://arxiv.org/abs/1302.3274
2013年5月8日星期三
Sequence logos
1. http://weblogo.berkeley.edu/logo.cgi
2. generate logo from alignment using R
http://davetang.org/muse/2013/01/30/sequence-logos-with-r/
2. generate logo from alignment using R
http://davetang.org/muse/2013/01/30/sequence-logos-with-r/
2013年5月1日星期三
订阅:
博文 (Atom)




