<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-6715598735361401237</atom:id><lastBuildDate>Mon, 16 Jan 2012 18:09:45 +0000</lastBuildDate><category>linux</category><category>Python</category><category>agriculture</category><category>genetics</category><category>web</category><category>INLA</category><category>LyX</category><category>graphics</category><category>animalScience</category><category>music</category><category>gheep</category><category>computers</category><category>poultry</category><category>life</category><category>LyX-Sweave</category><category>Sweave</category><category>SAS</category><category>biology</category><category>shell</category><category>si</category><category>study</category><category>writings</category><category>BUGS</category><category>joke</category><category>video</category><category>honeyBee</category><category>cattle</category><category>horses</category><category>statistics</category><category>Sweave.sh</category><category>data</category><category>LaTeX</category><category>talks</category><category>science</category><category>R</category><title>Gregor Gorjanc (gg)</title><description>About various things that cross my mind</description><link>http://ggorjan.blogspot.com/</link><managingEditor>noreply@blogger.com (Gregor Gorjanc)</managingEditor><generator>Blogger</generator><openSearch:totalResults>328</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/GregorGorjancsBlog" /><feedburner:info uri="gregorgorjancsblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-1136214481547223287</guid><pubDate>Tue, 03 Jan 2012 09:58:00 +0000</pubDate><atom:updated>2012-01-16T19:09:45.820+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">computers</category><category domain="http://www.blogger.com/atom/ns#">shell</category><category domain="http://www.blogger.com/atom/ns#">LaTeX</category><title>Compress PDF</title><description>&lt;div style="text-align: justify;"&gt;
See nice description &lt;a href="http://www.peteryu.ca/tutorials/publishing/pdf_manipulation_tips"&gt;here&lt;/a&gt;. In short using the command bellow on my Linux box (Windows users see &lt;a href="http://sourceforge.net/projects/pdfcreator/"&gt;PDFCreator&lt;/a&gt;) allowed me to reduce scanned color PDF for a factor of 4 to 5, e.g., from ~14 MB to &amp;nbsp;~3 MB. Supposedly PDFCreator also&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;gs -sDEVICE=pdfwrite -dMaxSubsetPct=100 -dPDFSETTINGS=/ebook -sOutputFile="out.pdf" -dNOPAUSE -dBATCH "in.pdf"&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;Update (2012-01-16): you can get a nice shell script called &lt;a href="https://sites.google.com/site/gregorgorjanc/software/compressPDF.sh"&gt;compressPDF.sh&lt;/a&gt; that saves some typing and can process multiple files, e.g.,&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;compressPDF.sh file.pdf&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-1136214481547223287?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/P_SP3RD8WS0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/P_SP3RD8WS0/compress-pdf.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2012/01/compress-pdf.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-238392073752221679</guid><pubDate>Fri, 16 Dec 2011 19:47:00 +0000</pubDate><atom:updated>2011-12-16T20:47:16.218+01:00</atom:updated><title>VIPER - cool pedigree&amp;genotype data view</title><description>Interested in genetics - in looking genotype data on pedigrees? Check out &lt;a href="http://www.viper-project.org.uk/"&gt;VIPER&lt;/a&gt;&amp;nbsp;(Visual Interactive Pedigree ExploreR). Looks really cool!!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-238392073752221679?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/zhMBqHapIrs" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/zhMBqHapIrs/viper-cool-pedigree-data-view.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/12/viper-cool-pedigree-data-view.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-1182802371321793023</guid><pubDate>Mon, 24 Oct 2011 22:17:00 +0000</pubDate><atom:updated>2011-10-28T01:37:30.634+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">statistics</category><category domain="http://www.blogger.com/atom/ns#">BUGS</category><category domain="http://www.blogger.com/atom/ns#">si</category><category domain="http://www.blogger.com/atom/ns#">talks</category><category domain="http://www.blogger.com/atom/ns#">INLA</category><title>Ocenjevanje parametrov v Bayesovski statistiki (IBMI)</title><description>&lt;div style="text-align: justify;"&gt;
Prosojnice z današnje predstavitve o ocenjevanju parametrov v Bayesovski statistiki na &lt;a href="http://ibmi.mf.uni-lj.si/ibmi/biostat-center/index.html"&gt;IBMI&lt;/a&gt; so na voljo &lt;a href="http://www.scribd.com/doc/70147317"&gt;tukaj&lt;/a&gt;.&lt;/div&gt;
&lt;a href="http://www.scribd.com/doc/70147317/Ocenjevanje-parametrov-v-Bayesovski-statistiki" style="display: block; font-family: Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; margin-bottom: 6px; margin-left: auto; margin-right: auto; margin-top: 12px; text-align: center; text-decoration: underline;" title="View Ocenjevanje parametrov v Bayesovski statistiki on Scribd"&gt;Ocenjevanje parametrov v Bayesovski statistiki&lt;/a&gt;&lt;iframe class="scribd_iframe_embed" data-aspect-ratio="1.33115468409586" data-auto-height="true" frameborder="0" height="600" id="doc_80757" scrolling="no" src="http://www.scribd.com/embeds/70147317/content?start_page=1&amp;amp;view_mode=slideshow&amp;amp;access_key=key-8dqh27dphqs526c37ij" width="100%"&gt;&lt;/iframe&gt;&lt;script type="text/javascript"&gt;
(function() { var scribd = document.createElement("script"); scribd.type = "text/javascript"; scribd.async = true; scribd.src = "http://www.scribd.com/javascripts/embed_code/inject.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(scribd, s); })();
&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-1182802371321793023?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/1JQk0Hmu3Vg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/1JQk0Hmu3Vg/ocenjevanje-parametrov-v-bayesovski.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/10/ocenjevanje-parametrov-v-bayesovski.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-2627232241278543990</guid><pubDate>Thu, 13 Oct 2011 20:18:00 +0000</pubDate><atom:updated>2011-10-13T22:18:05.299+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">video</category><category domain="http://www.blogger.com/atom/ns#">study</category><title>Recently discovered study resources</title><description>&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.khanacademy.org/"&gt;Khan Academy&lt;/a&gt; - a set of &lt;b&gt;2600&lt;/b&gt; free videos from basic to more advances quantitative skills&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ai-class.com/"&gt;Introduction to Artifical Inteligence&lt;/a&gt; -&amp;nbsp;Stanford&amp;nbsp;on-line course for masses&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ml-class.org/"&gt;Machine Learning&lt;/a&gt; -&amp;nbsp;Stanford&amp;nbsp;on-line course for masses&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-2627232241278543990?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/b7ivHQO2OnY" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/b7ivHQO2OnY/recently-discovered-study-resources.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/10/recently-discovered-study-resources.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-8768670089537023052</guid><pubDate>Wed, 05 Oct 2011 11:43:00 +0000</pubDate><atom:updated>2011-10-07T01:10:15.414+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">writings</category><category domain="http://www.blogger.com/atom/ns#">si</category><category domain="http://www.blogger.com/atom/ns#">gheep</category><title>Ovčereja na Norveškem</title><description>&lt;a href="http://www.scribd.com/doc/67581291/Ov%C4%8Dereja-na-Norve%C5%A1kem" style="-x-system-font: none; display: block; font-family: Helvetica,Arial,Sans-serif; font-size-adjust: none; font-size: 14px; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; margin: 12px auto 6px auto; text-decoration: underline;" title="View Ovčereja na Norveškem on Scribd"&gt;Ovčereja na Norveškem&lt;/a&gt;&lt;iframe class="scribd_iframe_embed" data-aspect-ratio="0.706697459584296" data-auto-height="true" frameborder="0" height="600" id="doc_95178" scrolling="no" src="http://www.scribd.com/embeds/67581291/content?start_page=1&amp;amp;view_mode=list&amp;amp;access_key=key-1vhuzo3r9v9g8jelth4m" width="100%"&gt;&lt;/iframe&gt;&lt;script type="text/javascript"&gt;
(function() { var scribd = document.createElement("script"); scribd.type = "text/javascript"; scribd.async = true; scribd.src = "http://www.scribd.com/javascripts/embed_code/inject.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(scribd, s); })();
&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-8768670089537023052?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/EKDSL1hEf48" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/EKDSL1hEf48/ovcereja-na-norveskem.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/10/ovcereja-na-norveskem.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-7014408255543613958</guid><pubDate>Tue, 04 Oct 2011 14:22:00 +0000</pubDate><atom:updated>2011-10-04T16:22:00.592+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">writings</category><title>ASD 2011 - Primošten</title><description>&lt;div style="text-align: justify;"&gt;Animal Science Days (ASD) conference was held in Primošten this year. I participated with the following contributions as a co-author:&lt;/div&gt;&lt;ul&gt;&lt;li style="text-align: justify;"&gt;Lambing Interval in Jezersko-Solčava and Improved Jezersko-Solčava Breed.&amp;nbsp;&lt;a href="http://www.scribd.com/doc/66868343"&gt;PDF&lt;/a&gt;&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;Partitioning of Genetic Trends by Originin Croatian Simmental Cattle. &lt;a href="http://www.scribd.com/doc/66874926"&gt;PDF&lt;/a&gt;&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;Estimation of Variance Components for Litter Size in the First and Later Parities in Improved Jezersko-Solcava Sheep. &lt;a href="http://www.scribd.com/doc/66874919"&gt;PDF&lt;/a&gt;&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;The Effect of Coenzyme Q10 and Lipoic Acid Added to the Feed of Hens on Physical Characteristics of Eggs. &lt;a href="http://www.scribd.com/doc/67444262"&gt;PDF&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-7014408255543613958?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/yyUVPr_i0II" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/yyUVPr_i0II/asd-2011-primosten.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/10/asd-2011-primosten.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-4724706555037734179</guid><pubDate>Thu, 29 Sep 2011 22:59:00 +0000</pubDate><atom:updated>2011-09-30T00:59:01.064+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">writings</category><category domain="http://www.blogger.com/atom/ns#">genetics</category><category domain="http://www.blogger.com/atom/ns#">animalScience</category><category domain="http://www.blogger.com/atom/ns#">talks</category><category domain="http://www.blogger.com/atom/ns#">cattle</category><title>InterBull: Partitioning of international genetic trends by origin in Brown Swiss bulls</title><description>&lt;div style="text-align: justify;"&gt;I attended the &lt;a href="http://www.interbull.org/index.php?option=com_content&amp;amp;view=article&amp;amp;id=89&amp;amp;Itemid=127"&gt;InterBull meeting&lt;/a&gt; this year in Stavanger (Norway), which was jointly organised with the &lt;a href="http://www.eaap.org/"&gt;EAAP&lt;/a&gt; conference in the same place. I participated with contribution titled "Partitioning of international genetic trends by origin in Brown Swiss bulls" co-authored with colleagues. In essence we partitioned &amp;nbsp;breeding values of Brown Swiss animals by origin of selection and summarized those partitions as origin specific genetic trends. This gives us an&amp;nbsp;opportunity&amp;nbsp;to evaluate the effect of selection performed in different countries and how this affects the global genetic trends. Results for this breed are quite shocking! Look into the paper and talk (see bellow) for more ;)&lt;br /&gt;
&lt;br /&gt;
We were&amp;nbsp;looking forward&amp;nbsp;for&amp;nbsp;comments&amp;nbsp;and/or critiques about the applied method&amp;nbsp;from the audience, but did not get any direct questions. Several people approached me after the talk and one of the comments was that our method is nothing more than multiplying breeding values by the share of genes coming from different origin. This is not true and I will demonstrate this in with a simple example.&lt;/div&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;Let us assume that we have a simple small pedigree as shown bellow with &lt;a href="http://www.r-project.org/"&gt;R&lt;/a&gt; code, where column names are: id =individual code, fid = father code, mid = mother code, ori = origin, and bv = breeding value. This pedigree could represent situation where we constantly use foreign sires - here only two generations are being shown. Origin represents the country of registering/selecting aninmal.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="overflow: auto;"&gt;&lt;div class="geshifilter"&gt;&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;## Simple example&lt;/span&gt;
&lt;a href="http://inside-r.org/r-doc/utils/example"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;example&lt;/span&gt;&lt;/a&gt; &amp;lt;- &lt;a href="http://inside-r.org/r-doc/base/data.frame"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;data.frame&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt; id=&lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;  &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;3&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;4&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;5&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;
                      fid=&lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt; &lt;span style="color: black; font-weight: bold;"&gt;NA&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;  &lt;span style="color: black; font-weight: bold;"&gt;NA&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;  &lt;span style="color: black; font-weight: bold;"&gt;NA&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;3&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;
                      mid=&lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt; &lt;span style="color: black; font-weight: bold;"&gt;NA&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;  &lt;span style="color: black; font-weight: bold;"&gt;NA&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;  &lt;span style="color: black; font-weight: bold;"&gt;NA&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;4&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;
                      ori=&lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;"A"&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;"B"&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;"A"&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;"B"&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;"A"&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;
                       bv=&lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;100&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;106&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;104&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;106&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;103&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;Now we would like to perform gene proportion analysis and partitioning of supplied breeding values, both according to origin. This is easy to achieve "by hand" for this simple example (see paper bellow for maths), but tedious for bigger examples. I have wrote an R package &lt;b&gt;partAGV&lt;/b&gt; (not yet&amp;nbsp;publicly&amp;nbsp;available, but you can contact me) that can be used for such analyses.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="overflow: auto;"&gt;&lt;div class="geshifilter"&gt;&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;## For gene proportion analysis&lt;/span&gt;
&lt;a href="http://inside-r.org/r-doc/utils/example"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;example&lt;/span&gt;&lt;/a&gt;$gp &amp;lt;- &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;
&amp;nbsp;
&lt;a href="http://inside-r.org/r-doc/base/library"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;library&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;partAGV&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
partAGV&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/utils/example"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;example&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; colAGV=&lt;span style="color: #cc66cc;"&gt;6&lt;/span&gt;:&lt;span style="color: #cc66cc;"&gt;5&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&amp;nbsp;
&lt;span style="color: #666666; font-style: italic;"&gt;## Gene proportions&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##    id  fid  mid ori gp gp_pa gp_w gp_A gp_B&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 1   1 &amp;lt;NA&amp;gt; &amp;lt;NA&amp;gt;   A  1     0    1 1.00 0.00&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 2   2 &amp;lt;NA&amp;gt; &amp;lt;NA&amp;gt;   B  1     0    1 0.00 1.00&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 3   3    1    2   A  1     1    0 0.50 0.50&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 4   4 &amp;lt;NA&amp;gt; &amp;lt;NA&amp;gt;   B  1     0    1 0.00 1.00&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 5   5    3    4   A  1     1    0 0.25 0.75&lt;/span&gt;
&amp;nbsp;
&lt;span style="color: #666666; font-style: italic;"&gt;## Partitions of breeding values &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##    id  fid  mid ori  bv bv_pa bv_w  bv_A  bv_B&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 1   1 &amp;lt;NA&amp;gt; &amp;lt;NA&amp;gt;   A 100     0  100 100.0   0.0&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 2   2 &amp;lt;NA&amp;gt; &amp;lt;NA&amp;gt;   B 106     0  106   0.0 106.0&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 3   3    1    2   A 104   103    1  51.0  53.0&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 4   4 &amp;lt;NA&amp;gt; &amp;lt;NA&amp;gt;   B 106     0  106   0.0 106.0&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 5   5    3    4   A 103   105   -2  23.5  79.5&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div&gt;&lt;div style="text-align: justify;"&gt;As we can see gene proportions are as expected: 1/2 for each origin in individual 3 and 1/4 vs. 3/4 for individual 5. Partitions of breeding values show that in animal 5 we 23.5 (out of 105) is attributed to selection work done in country A and 79.5 is attributed to selection work done in country B. Now, if we multiply breeding value of individual 5 (105) by origin specific gene proportions (1/4 and 3/4) we get&amp;nbsp;25.75 and 77.5, which is similar to partitions, but not the same. This shows that our method enables separation of gene flow and selection work preformed by particular country. In order to see this algebraically we can write&amp;nbsp;breeding values of this individual as:&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;a_5 &amp;nbsp; = 1/2 a_3 + 1/2 a_4 + w_5&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; = 1/2 (1/2 a_1 + 1/2 a_2 &amp;nbsp; + &amp;nbsp; &amp;nbsp; w_3) &amp;nbsp;+ 1/2 w_4 + w_5&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; = &amp;nbsp; &amp;nbsp; &amp;nbsp;1/4 a_1 + 1/4 a_2 &amp;nbsp; + 1/2 w_3 &amp;nbsp; + 1/2 w_4 + w_5&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; = &amp;nbsp; &amp;nbsp; &amp;nbsp;1/4 w_1 + 1/4 w_2 &amp;nbsp; + 1/2 w_3 &amp;nbsp; + 1/2 w_4 + w_5&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; = &amp;nbsp; &amp;nbsp; &amp;nbsp;1/4 100 + 1/4 106 &amp;nbsp; + 1/2 &amp;nbsp; 1 &amp;nbsp; + 1/2 106 + &amp;nbsp;-2&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; = &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25 + &amp;nbsp; &amp;nbsp; &amp;nbsp;26.5 + &amp;nbsp; &amp;nbsp; &amp;nbsp; 0.5 + &amp;nbsp; &amp;nbsp; &amp;nbsp;53 + &amp;nbsp;-2&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;
If we now collect terms specific to each origin we get:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;a_5_A = &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25 + &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0.5 + &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; + &amp;nbsp;-2 = 23.5&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;a_5_B = &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 26.5 + &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;53 &amp;nbsp; &amp;nbsp; &amp;nbsp; = 79.5&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;a href="http://www.scribd.com/doc/66867813/Partitioning-of-international-genetic-trends-by-origin-in-Brown-Swiss-bulls" style="display: inline !important; font-family: Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; margin-bottom: 6px; margin-left: auto; margin-right: auto; margin-top: 12px; text-decoration: underline;" title="View Partitioning of international genetic trends by origin in Brown Swiss bulls on Scribd"&gt;Partitioning of international genetic trends by origin in Brown Swiss bulls&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;iframe class="scribd_iframe_embed" data-aspect-ratio="1.29411764705882" data-auto-height="true" frameborder="0" height="600" id="doc_70686" scrolling="no" src="http://www.scribd.com/embeds/66867813/content?start_page=1&amp;amp;view_mode=list&amp;amp;access_key=key-1u10h0qtvxfbs8m3oziy" width="100%"&gt;&lt;/iframe&gt;&lt;script type="text/javascript"&gt;
(function() { var scribd = document.createElement("script"); scribd.type = "text/javascript"; scribd.async = true; scribd.src = "http://www.scribd.com/javascripts/embed_code/inject.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(scribd, s); })();
&lt;/script&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div&gt;&lt;a href="http://www.scribd.com/doc/66867776/Partitioning-of-international-genetic-trends-by-origin-in-Brown-Swiss-bulls" style="-x-system-font: none; display: block; font-family: Helvetica,Arial,Sans-serif; font-size-adjust: none; font-size: 14px; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; margin: 12px auto 6px auto; text-decoration: underline;" title="View Partitioning of international genetic trends by origin in Brown Swiss bulls on Scribd"&gt;Partitioning of international genetic trends by origin in Brown Swiss bulls&lt;/a&gt;&lt;iframe class="scribd_iframe_embed" data-aspect-ratio="0.772727272727273" data-auto-height="true" frameborder="0" height="600" id="doc_91843" scrolling="no" src="http://www.scribd.com/embeds/66867776/content?start_page=1&amp;amp;view_mode=list&amp;amp;access_key=key-45n6y72928kxsrgfjmt" width="100%"&gt;&lt;/iframe&gt;&lt;script type="text/javascript"&gt;
(function() { var scribd = document.createElement("script"); scribd.type = "text/javascript"; scribd.async = true; scribd.src = "http://www.scribd.com/javascripts/embed_code/inject.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(scribd, s); })();
&lt;/script&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-4724706555037734179?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/7Th24N3NSsI" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/7Th24N3NSsI/interbull-partitioning-of-international.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/09/interbull-partitioning-of-international.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-8080890805044474096</guid><pubDate>Wed, 28 Sep 2011 12:50:00 +0000</pubDate><atom:updated>2011-09-28T14:50:20.147+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">genetics</category><category domain="http://www.blogger.com/atom/ns#">agriculture</category><category domain="http://www.blogger.com/atom/ns#">R</category><title>Polyploidy in sugarcane</title><description>&lt;div style="text-align: justify;"&gt;While reading &lt;a href="http://www.warwick.ac.uk/statsdept/user-2011/"&gt;UseR conference&lt;/a&gt; abstracts I came across this sentence: "Sugarcane is polypoid, i.e., has 8 to 14 copies of every chromosome, with individual alleles in varying numbers." Vau! This generates really complex genotype system. Say we have biallelic gene with alleles being A and B. In diploids the possible genotypes are AA, AB, and BB. Given the above sentence in sugarcane possible genotypes are any permutation of A's and B's in a series of 8 to 14 alleles. I am not sure if 9, 11, and 13 are also allowed, that is having even number of chromosomes. In any case such permutations result&amp;nbsp;in really large numbers!&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Thinking about this a bit further it appears that the whole system is not that complex once we realize that genotyping does not tell as about the order of alleles (we can not&amp;nbsp;distinguish&amp;nbsp;between AB and BA), which simplifies from all possible permutations to all possible combinations, e.g., for biallelic gene in tetraploids this would correspond to 5 combinations and 16 permutations.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Bellow is an R snippet that shows how to enumerate all possible combinations or permutations&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;div style="overflow: auto;"&gt;&lt;div class="geshifilter"&gt;&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;## Load package having nice combinatorial functions&lt;/span&gt;
&lt;a href="http://inside-r.org/r-doc/base/library"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;library&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;package=&lt;span style="color: blue;"&gt;"gtools"&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&amp;nbsp;
&lt;span style="color: #666666; font-style: italic;"&gt;## Specify alleles - just two for simplicity&lt;/span&gt;
alleles &amp;lt;- &lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;"A"&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;"B"&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&amp;nbsp;
&lt;span style="color: #666666; font-style: italic;"&gt;## Possible genotypes for diploids&lt;/span&gt;
combinations&lt;span style="color: #009900;"&gt;(&lt;/span&gt;n=&lt;a href="http://inside-r.org/r-doc/base/length"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;length&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;alleles&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; r=&lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; v=alleles&lt;span style="color: #339933;"&gt;,&lt;/span&gt; repeats.allowed=&lt;span style="color: black; font-weight: bold;"&gt;TRUE&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##      [,1] [,2]&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [1,] "A"  "A" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [2,] "A"  "B" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [3,] "B"  "B" &lt;/span&gt;
&amp;nbsp;
&lt;span style="color: #666666; font-style: italic;"&gt;## Possible genotypes for tetraploids&lt;/span&gt;
combinations&lt;span style="color: #009900;"&gt;(&lt;/span&gt;n=&lt;a href="http://inside-r.org/r-doc/base/length"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;length&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;alleles&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; r=&lt;span style="color: #cc66cc;"&gt;4&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; v=alleles&lt;span style="color: #339933;"&gt;,&lt;/span&gt; repeats.allowed=&lt;span style="color: black; font-weight: bold;"&gt;TRUE&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;ž
&lt;span style="color: #666666; font-style: italic;"&gt;##      [,1] [,2] [,3] [,4]&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [1,] "A"  "A"  "A"  "A" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [2,] "A"  "A"  "A"  "B" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [3,] "A"  "A"  "B"  "B" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [4,] "A"  "B"  "B"  "B" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [5,] "B"  "B"  "B"  "B" &lt;/span&gt;
&amp;nbsp;
permutations&lt;span style="color: #009900;"&gt;(&lt;/span&gt;n=&lt;a href="http://inside-r.org/r-doc/base/length"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;length&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;alleles&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; r=&lt;span style="color: #cc66cc;"&gt;4&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; v=alleles&lt;span style="color: #339933;"&gt;,&lt;/span&gt; repeats.allowed=&lt;span style="color: black; font-weight: bold;"&gt;TRUE&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##       [,1] [,2] [,3] [,4]&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [1,] "A"  "A"  "A"  "A" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [2,] "A"  "A"  "A"  "B" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [3,] "A"  "A"  "B"  "A" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [4,] "A"  "A"  "B"  "B" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [5,] "A"  "B"  "A"  "A" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [6,] "A"  "B"  "A"  "B" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [7,] "A"  "B"  "B"  "A" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [8,] "A"  "B"  "B"  "B" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [9,] "B"  "A"  "A"  "A" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [10,] "B"  "A"  "A"  "B" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [11,] "B"  "A"  "B"  "A" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [12,] "B"  "A"  "B"  "B" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [13,] "B"  "B"  "A"  "A" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [14,] "B"  "B"  "A"  "B" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [15,] "B"  "B"  "B"  "A" &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [16,] "B"  "B"  "B"  "B" &lt;/span&gt;
&amp;nbsp;
&lt;span style="color: #666666; font-style: italic;"&gt;## Possible genotypes for 8-14 ploids&lt;/span&gt;
&lt;a href="http://inside-r.org/r-doc/stats/spectrum"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;spectrum&lt;/span&gt;&lt;/a&gt; &amp;lt;- &lt;a href="http://inside-r.org/r-doc/base/seq"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;seq&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;from=&lt;span style="color: #cc66cc;"&gt;8&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; to=&lt;span style="color: #cc66cc;"&gt;14&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/by"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;by&lt;/span&gt;&lt;/a&gt;=&lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
nS &amp;lt;- &lt;a href="http://inside-r.org/r-doc/base/length"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;length&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/stats/spectrum"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;spectrum&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
retC &amp;lt;- &lt;a href="http://inside-r.org/r-doc/base/vector"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;vector&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/mode"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;mode&lt;/span&gt;&lt;/a&gt;=&lt;span style="color: blue;"&gt;"list"&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/length"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;length&lt;/span&gt;&lt;/a&gt;=nS&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
retP &amp;lt;- &lt;a href="http://inside-r.org/r-doc/base/vector"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;vector&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/mode"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;mode&lt;/span&gt;&lt;/a&gt;=&lt;span style="color: blue;"&gt;"list"&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/length"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;length&lt;/span&gt;&lt;/a&gt;=nS&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&lt;span style="color: black; font-weight: bold;"&gt;for&lt;/span&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;i &lt;span style="color: black; font-weight: bold;"&gt;in&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;:nS&lt;span style="color: #009900;"&gt;)&lt;/span&gt; &lt;span style="color: #009900;"&gt;{&lt;/span&gt;
  retC&lt;span style="color: #009900;"&gt;[&lt;/span&gt;&lt;span style="color: #009900;"&gt;[&lt;/span&gt;i&lt;span style="color: #009900;"&gt;]&lt;/span&gt;&lt;span style="color: #009900;"&gt;]&lt;/span&gt; &amp;lt;- combinations&lt;span style="color: #009900;"&gt;(&lt;/span&gt;n=&lt;a href="http://inside-r.org/r-doc/base/length"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;length&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;alleles&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; r=&lt;a href="http://inside-r.org/r-doc/stats/spectrum"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;spectrum&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;[&lt;/span&gt;i&lt;span style="color: #009900;"&gt;]&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; v=alleles&lt;span style="color: #339933;"&gt;,&lt;/span&gt; repeats.allowed=&lt;span style="color: black; font-weight: bold;"&gt;TRUE&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
  retP&lt;span style="color: #009900;"&gt;[&lt;/span&gt;&lt;span style="color: #009900;"&gt;[&lt;/span&gt;i&lt;span style="color: #009900;"&gt;]&lt;/span&gt;&lt;span style="color: #009900;"&gt;]&lt;/span&gt; &amp;lt;- permutations&lt;span style="color: #009900;"&gt;(&lt;/span&gt;n=&lt;a href="http://inside-r.org/r-doc/base/length"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;length&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;alleles&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; r=&lt;a href="http://inside-r.org/r-doc/stats/spectrum"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;spectrum&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;[&lt;/span&gt;i&lt;span style="color: #009900;"&gt;]&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; v=alleles&lt;span style="color: #339933;"&gt;,&lt;/span&gt; repeats.allowed=&lt;span style="color: black; font-weight: bold;"&gt;TRUE&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&lt;span style="color: #009900;"&gt;}&lt;/span&gt;
combC &amp;lt;- &lt;a href="http://inside-r.org/r-doc/base/sapply"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;sapply&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;retC&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/nrow"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;nrow&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
combP &amp;lt;- &lt;a href="http://inside-r.org/r-doc/base/sapply"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;sapply&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;retP&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/nrow"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;nrow&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&lt;a href="http://inside-r.org/r-doc/base/cbind"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;cbind&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/stats/spectrum"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;spectrum&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; combC&lt;span style="color: #339933;"&gt;,&lt;/span&gt; combP&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##      spectrum combC combP&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [1,]        8     9   256&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [2,]       10    11  1024&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [3,]       12    13  4096&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [4,]       14    15 16384&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;a href="http://www.inside-r.org/pretty-r" title="Created by Pretty R at inside-R.org"&gt;Created by Pretty R at inside-R.org&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-8080890805044474096?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/GNRlFt7qjqg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/GNRlFt7qjqg/polyploidy-in-sugarcane.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/09/polyploidy-in-sugarcane.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-5436463214104826881</guid><pubDate>Thu, 11 Aug 2011 22:58:00 +0000</pubDate><atom:updated>2011-11-05T17:06:40.715+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">genetics</category><category domain="http://www.blogger.com/atom/ns#">animalScience</category><category domain="http://www.blogger.com/atom/ns#">R</category><title>Setup up the inverse of additive relationship matrix in R</title><description>&lt;div style="text-align: justify;"&gt;
Additive genetic covariance between individuals is one of the key concepts in &lt;a href="http://en.wikipedia.org/wiki/Quantitative_genetics"&gt;(quantitative) genetics&lt;/a&gt;. When doing the&amp;nbsp;prediction&amp;nbsp;of additive genetic values for pedigree members, we need the inverse of the so called numerator relationship matrix (NRM) or simply&amp;nbsp;&lt;b&gt;A&lt;/b&gt;. Matrix &lt;b&gt;A&lt;/b&gt; has off-diagonal entries equal to numerator of &lt;a href="http://en.wikipedia.org/wiki/Sewall_Wright"&gt;Wright&lt;/a&gt;'s relationship coefficient and diagonal elements equal to 1 + inbreeding coefficient. I have blogged before about setting up such inverse in R using routine from the &lt;a href="http://ggorjan.blogspot.com/2010/12/asreml-r-storing-inverse-as-matrix.html"&gt;ASReml-R program&lt;/a&gt; or importing the inverse from the &lt;a href="http://ggorjan.blogspot.com/2008/07/cfc-program-contribution-inbreeding-f.html"&gt;CFC program&lt;/a&gt;. However, this is not the only way to "skin this cat" in R. I am aware of the following attempts to provide this feature in R for various things (the list is probably incomplete and I would&amp;nbsp;grateful&amp;nbsp;if you point me to other implementations):&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://cran.r-project.org/web/packages/pedigree/index.html"&gt;pedigree&lt;/a&gt;&amp;nbsp;R package has function &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;makeA()&lt;/span&gt; and &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;makeAinv()&lt;/span&gt; with obvious meanings; there is also &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;calcG()&lt;/span&gt; if you have a lot of marker data instead of pedigree information; there are also some other very handy functions &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;calcInbreeding()&lt;/span&gt;, &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;orderPed()&lt;/span&gt;, &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;trimPed()&lt;/span&gt;, etc.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://cran.r-project.org/web/packages/pedigree/index.html"&gt;pedigreemm&lt;/a&gt; R package does not have direct implementation to get &lt;b&gt;A&lt;/b&gt; inverse, but has all the needed ingredients, which makes the package even more interesting&lt;/li&gt;
&lt;li&gt;&lt;a href="http://cran.r-project.org/web/packages/MCMCglmm/index.html"&gt;MCMCglmm&lt;/a&gt; R package has function &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;inverseA()&lt;/span&gt;&amp;nbsp;which works with pedigree or phlyo objects; there are also handy functions such as &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;prunePed()&lt;/span&gt;, &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;rbv()&lt;/span&gt;,&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sm2asreml()&lt;/span&gt;, etc.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://cran.r-project.org/web/packages/kinship/index.html"&gt;kinship&lt;/a&gt; and &lt;a href="http://cran.r-project.org/web/packages/kinship2/index.html"&gt;kinship2&lt;/a&gt; R packages have function &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;kinship()&lt;/span&gt; to setup kinship matrix, which is equal to the half of &lt;b&gt;A&lt;/b&gt;; there are also nice functions for plotting pedigrees etc. (see also &lt;a href="http://ggorjan.blogspot.com/2010/06/drawing-pedigree-examples-using-kinship.html"&gt;here&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;see also a series of &lt;a href="http://www.ansci.wisc.edu/morota/R/relmat.html"&gt;R scripts&lt;/a&gt; for relationship matrices&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="text-align: justify;"&gt;
As I described &lt;a href="http://ggorjan.blogspot.com/2010/12/asreml-r-storing-inverse-as-matrix.html"&gt;before&lt;/a&gt;, the interesting thing is that setting up inverse of &lt;b&gt;A&lt;/b&gt; is easier and cheaper than setting up A and inverting it. This is very important for large applications. This is an old result using the following matrix theory. We can decompose symmetric positive definite matrix as &lt;b&gt;A&lt;/b&gt; = &lt;b&gt;LU&lt;/b&gt; = &lt;b&gt;LL&lt;/b&gt;'&lt;b&gt;&amp;nbsp;&lt;/b&gt;(Cholesky decomposition)&amp;nbsp;or as &lt;b&gt;A&lt;/b&gt; = &lt;b&gt;LDU&lt;/b&gt; = &lt;b&gt;LDL&lt;/b&gt;' (Generalized Cholesky decomposition), where &lt;b&gt;L&lt;/b&gt; (&lt;b&gt;U&lt;/b&gt;) is lower (upper) triangular, and &lt;b&gt;D&lt;/b&gt; is diagonal matrix. Note that &lt;b&gt;L&lt;/b&gt; and &lt;b&gt;U&lt;/b&gt; in&amp;nbsp;previous two equations are not the same thing (&lt;b&gt;L&lt;/b&gt; from Cholesky is not equal to &lt;b&gt;L&lt;/b&gt; from Generalized Cholesky decomposition)! Sorry for&amp;nbsp;sloppy&amp;nbsp;notation. In order to confuse you even more note that Henderson usually wrote &lt;b&gt;A&lt;/b&gt; = &lt;b&gt;TDT&lt;/b&gt;'. We can even do &lt;b&gt;A&lt;/b&gt; = &lt;b&gt;LSSU&lt;/b&gt;, where &lt;b&gt;S&lt;/b&gt;&amp;nbsp;diagonal is equal to the square root of &lt;b&gt;D&lt;/b&gt; diagonal. This can get us back to &lt;b&gt;A&lt;/b&gt; = &lt;b&gt;LU&lt;/b&gt; = &lt;b&gt;LL&lt;/b&gt;'&amp;nbsp;as &lt;b&gt;LSSU&lt;/b&gt; = &lt;b&gt;LSSL&lt;/b&gt;' = &lt;b&gt;LS&lt;/b&gt;&lt;b&gt;S&lt;/b&gt;'&lt;b&gt;L&lt;/b&gt;'&amp;nbsp;= &lt;b&gt;LS&lt;/b&gt;(&lt;b&gt;LS&lt;/b&gt;)'&lt;b&gt;&amp;nbsp;= L&lt;/b&gt;'&lt;b&gt;L&lt;/b&gt; (again be ware of sloppy notation)! The inverse rule says that inv(&lt;b&gt;A&lt;/b&gt;) = inv(&lt;b&gt;LDU&lt;/b&gt;) = inv(&lt;b&gt;U&lt;/b&gt;) inv(&lt;b&gt;D&lt;/b&gt;) inv(&lt;b&gt;L&lt;/b&gt;) =&amp;nbsp;inv(&lt;b&gt;L&lt;/b&gt;)' inv(&lt;b&gt;D&lt;/b&gt;) inv(&lt;b&gt;L&lt;/b&gt;) =&amp;nbsp;inv(&lt;b&gt;L&lt;/b&gt;)' inv(&lt;b&gt;S&lt;/b&gt;) inv(&lt;b&gt;S&lt;/b&gt;) inv(&lt;b&gt;L&lt;/b&gt;).&amp;nbsp;I thank to&amp;nbsp;&lt;a href="http://stat.ethz.ch/people/maechler"&gt;Martin Maechler&lt;/a&gt;&amp;nbsp;for pointing out to the last (obviously) bit to me.&amp;nbsp;In Henderson's notation this would be&amp;nbsp;inv(&lt;b&gt;A&lt;/b&gt;) =&amp;nbsp;inv(&lt;b&gt;T&lt;/b&gt;)' inv(&lt;b&gt;D&lt;/b&gt;) inv(&lt;b&gt;T&lt;/b&gt;) =&amp;nbsp;inv(&lt;b&gt;T&lt;/b&gt;)' inv(&lt;b&gt;S&lt;/b&gt;) inv(&lt;b&gt;S&lt;/b&gt;) inv(&lt;b&gt;T&lt;/b&gt;)&amp;nbsp;Uf ... The important bit is that with&lt;b&gt;&amp;nbsp;&lt;/b&gt;NRM (aka &lt;b&gt;A&lt;/b&gt;) inv(&lt;b&gt;L&lt;/b&gt;) has nice simple structure - it shows the directed graph of additive genetic values in pedigree, while inv(&lt;b&gt;D&lt;/b&gt;) tells us about the precision (inverse variance) of additive genetic values given the additive genetic values of parents and therefore depends on knowledge of parents and their inbreeding (the more they are inbred less variation can we expect in their progeny). Both inv(&lt;b&gt;L&lt;/b&gt;) and inv(&lt;b&gt;D&lt;/b&gt;) are easier to setup.&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Packages &lt;a href="http://cran.r-project.org/web/packages/MCMCglmm/index.html"&gt;MCMCglmm&lt;/a&gt; and &lt;a href="http://cran.r-project.org/web/packages/pedigree/index.html"&gt;pedigree&lt;/a&gt; give us inv(&lt;b&gt;A&lt;/b&gt;) directly (we can also get inv(&lt;b&gt;D&lt;/b&gt;) in &lt;a href="http://cran.r-project.org/web/packages/MCMCglmm/index.html"&gt;MCMCglmm&lt;/a&gt;), but &lt;a href="http://cran.r-project.org/web/packages/pedigreemm/index.html"&gt;pedigreemm&lt;/a&gt;&amp;nbsp;enables us to play around with the above matrix algebra and graph theory. First we need a small example pedigree. Bellow is an example with 10 members and there is also some inbreeding and some individuals have both, one, or no parents known. It is hard to see inbreeding directly from the table, but we will improve that later&amp;nbsp;(see also&amp;nbsp;&lt;a href="http://ggorjan.blogspot.com/2010/06/drawing-pedigree-examples-using-kinship.html"&gt;here&lt;/a&gt;).&lt;/div&gt;
&lt;br /&gt;
&lt;div style="overflow: auto;"&gt;
&lt;div class="geshifilter"&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;ped &amp;lt;- &lt;a href="http://inside-r.org/r-doc/base/data.frame"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;data.frame&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt; id=&lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;  &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;3&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;4&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;5&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;6&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;7&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;8&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;9&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;  &lt;span style="color: #cc66cc;"&gt;10&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;
                  fid=&lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt; &lt;span style="color: black; font-weight: bold;"&gt;NA&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;  &lt;span style="color: black; font-weight: bold;"&gt;NA&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;4&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;5&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;5&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;  &lt;span style="color: black; font-weight: bold;"&gt;NA&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;8&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;
                  mid=&lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt; &lt;span style="color: black; font-weight: bold;"&gt;NA&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;  &lt;span style="color: black; font-weight: bold;"&gt;NA&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;  &lt;span style="color: black; font-weight: bold;"&gt;NA&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;3&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;3&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;6&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;6&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;  &lt;span style="color: black; font-weight: bold;"&gt;NA&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;   &lt;span style="color: #cc66cc;"&gt;9&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Now we will create an object of a pedigree class and show the &lt;b&gt;A&lt;/b&gt; = &lt;b&gt;U&lt;/b&gt;'&lt;b&gt;U&lt;/b&gt; stuff:&lt;/div&gt;
&lt;br /&gt;
&lt;div style="overflow: auto;"&gt;
&lt;div class="geshifilter"&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;## install.packages(pkgs="pedigreemm")&lt;/span&gt;
&lt;a href="http://inside-r.org/r-doc/base/library"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;library&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;package=&lt;span style="color: blue;"&gt;"pedigreemm"&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&amp;nbsp;
ped2 &amp;lt;- &lt;a href="http://inside-r.org/r-doc/base/with"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;with&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;ped&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/packages/cran/pedigree"&gt;pedigree&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;sire=fid&lt;span style="color: #339933;"&gt;,&lt;/span&gt; dam=mid&lt;span style="color: #339933;"&gt;,&lt;/span&gt; label=id&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&amp;nbsp;
U &amp;lt;- relfactor&lt;span style="color: #009900;"&gt;(&lt;/span&gt;ped2&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
A &amp;lt;- &lt;a href="http://inside-r.org/r-doc/base/crossprod"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;crossprod&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;U&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&amp;nbsp;
&lt;a href="http://inside-r.org/r-doc/base/round"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;round&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;U&lt;span style="color: #339933;"&gt;,&lt;/span&gt; digits=&lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 10 x 10 sparse Matrix of class "dtCMatrix"                                     &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [1,] 1 . 0.50 .    0.25 0.25 0.25 0.25 . 0.12&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [2,] . 1 0.50 0.50 0.50 0.75 0.62 0.62 . 0.31&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [3,] . . 0.71 .    0.35 0.35 0.35 0.35 . 0.18&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [4,] . . .    0.87 0.43 .    0.22 0.22 . 0.11&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [5,] . . .    .    0.71 .    0.35 0.35 . 0.18&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [6,] . . .    .    .    0.71 0.35 0.35 . 0.18&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [7,] . . .    .    .    .    0.64 .    . .   &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [8,] . . .    .    .    .    .    0.64 . 0.32&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [9,] . . .    .    .    .    .    .    1 0.50&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [10,] . . .    .    .    .    .    .    . 0.66&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;## To check&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;U - chol(A)
&lt;span style="color: #003399; font-weight: bold;"&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;&lt;a href="http://inside-r.org/r-doc/base/round"&gt;round&lt;/a&gt;&lt;/span&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;A&lt;span style="color: #339933;"&gt;,&lt;/span&gt; digits=&lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 10 x 10 sparse Matrix of class "dsCMatrix"                                     &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [1,] 1.00 .    0.50 .    0.25 0.25 0.25 0.25 .   0.12&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [2,] .    1.00 0.50 0.50 0.50 0.75 0.62 0.62 .   0.31&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [3,] 0.50 0.50 1.00 0.25 0.62 0.75 0.69 0.69 .   0.34&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [4,] .    0.50 0.25 1.00 0.62 0.38 0.50 0.50 .   0.25&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [5,] 0.25 0.50 0.62 0.62 1.12 0.56 0.84 0.84 .   0.42&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [6,] 0.25 0.75 0.75 0.38 0.56 1.25 0.91 0.91 .   0.45&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [7,] 0.25 0.62 0.69 0.50 0.84 0.91 1.28 0.88 .   0.44&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [8,] 0.25 0.62 0.69 0.50 0.84 0.91 0.88 1.28 .   0.64&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [9,] .    .    .    .    .    .    .    .    1.0 0.50&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [10,] 0.12 0.31 0.34 0.25 0.42 0.45 0.44 0.64 0.5 1.00&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Note that pedigreemm package uses Matrix classes in order to store only what we need to store, e.g., matrix &lt;b&gt;U&lt;/b&gt; is triangular (t in "dtCMatrix") and matrix &lt;b&gt;A&lt;/b&gt; is symmetric (s in "dsCMatrix"). To show the generalized Cholesky &lt;b&gt;A&lt;/b&gt; = &lt;b&gt;LDU&lt;/b&gt;&amp;nbsp;(or using Henderson notation &lt;b&gt;A&lt;/b&gt; = &lt;b&gt;TDT&lt;/b&gt;') we use gchol() from the&amp;nbsp;&lt;a href="http://cran.r-project.org/web/packages/bdsmatrix/index.html"&gt;bdsmatrix&lt;/a&gt; R package. Matrix&amp;nbsp;&lt;b&gt;T&lt;/b&gt; shows the "flow" of genes in pedigree.&lt;/div&gt;
&lt;br /&gt;
&lt;div style="overflow: auto;"&gt;
&lt;div class="geshifilter"&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;## install.packages(pkgs="bdsmatrix")&lt;/span&gt;
&lt;a href="http://inside-r.org/r-doc/base/library"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;library&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;package=&lt;span style="color: blue;"&gt;"bdsmatrix"&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
tmp &amp;lt;- gchol&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/as.matrix"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;as.matrix&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;A&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&lt;a href="http://inside-r.org/r-doc/stats/D"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;D&lt;/span&gt;&lt;/a&gt; &amp;lt;- &lt;a href="http://inside-r.org/r-doc/base/diag"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;diag&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;tmp&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&lt;span style="color: #009900;"&gt;(&lt;/span&gt;T &amp;lt;- &lt;a href="http://inside-r.org/r-doc/methods/as"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;as&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/as.matrix"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;as.matrix&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;tmp&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;"dtCMatrix"&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 10 x 10 sparse Matrix of class "dtCMatrix"                                     &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [1,] 1.000 .      .    .     .    .    . .   .   .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [2,] .     1.0000 .    .     .    .    . .   .   .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [3,] 0.500 0.5000 1.00 .     .    .    . .   .   .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [4,] .     0.5000 .    1.000 .    .    . .   .   .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [5,] 0.250 0.5000 0.50 0.500 1.00 .    . .   .   .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [6,] 0.250 0.7500 0.50 .     .    1.00 . .   .   .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [7,] 0.250 0.6250 0.50 0.250 0.50 0.50 1 .   .   .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [8,] 0.250 0.6250 0.50 0.250 0.50 0.50 . 1.0 .   .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [9,] .     .      .    .     .    .    . .   1.0 .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [10,] 0.125 0.3125 0.25 0.125 0.25 0.25 . 0.5 0.5 1&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;## To check&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;L&amp;nbsp;&lt;/span&gt;&amp;lt;- T %*% &lt;a href="http://inside-r.org/r-doc/base/diag"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;diag&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/sqrt"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;sqrt&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;DInv&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #009900;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;L - t(U)&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Now the &lt;b&gt;A&lt;/b&gt; inverse part (inv(&lt;b&gt;A&lt;/b&gt;) = inv(&lt;b&gt;T&lt;/b&gt;)' inv(&lt;b&gt;D&lt;/b&gt;) inv(&lt;b&gt;T&lt;/b&gt;) =&amp;nbsp;inv(&lt;b&gt;T&lt;/b&gt;)' inv(&lt;b&gt;S&lt;/b&gt;) inv(&lt;b&gt;S&lt;/b&gt;) inv(&lt;b&gt;T&lt;/b&gt;) using Henderson's notation, note that ). The nice thing is that pedigreemm authors provided functions to get inv(&lt;b&gt;T&lt;/b&gt;) and &lt;b&gt;D&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="overflow: auto;"&gt;
&lt;div class="geshifilter"&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;TInv &amp;lt;- &lt;a href="http://inside-r.org/r-doc/methods/as"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;as&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;ped2&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;"sparseMatrix"&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 10 x 10 sparse Matrix of class "dtCMatrix" (unitriangular)            &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 1   1.0  .    .    .    .    .   .  .    .   .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 2   .    1.0  .    .    .    .   .  .    .   .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 3  -0.5 -0.5  1.0  .    .    .   .  .    .   .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 4   .   -0.5  .    1.0  .    .   .  .    .   .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 5   .    .   -0.5 -0.5  1.0  .   .  .    .   .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 6   .   -0.5 -0.5  .    .    1.0 .  .    .   .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 7   .    .    .    .   -0.5 -0.5 1  .    .   .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 8   .    .    .    .   -0.5 -0.5 .  1.0  .   .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 9   .    .    .    .    .    .   .  .    1.0 .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 10  .    .    .    .    .    .   . -0.5 -0.5 1&lt;/span&gt;
&lt;a href="http://inside-r.org/r-doc/base/round"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;round&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;DInv &amp;lt;- &lt;a href="http://inside-r.org/r-doc/Matrix/Diagonal"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Diagonal&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;x=&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;/Dmat&lt;span style="color: #009900;"&gt;(&lt;/span&gt;ped2&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; digits=&lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 10 x 10 diagonal matrix of class "ddiMatrix"&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [1,]    1    .    .    .    .    .    .    .    .     .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [2,]    .    1    .    .    .    .    .    .    .     .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [3,]    .    .    2    .    .    .    .    .    .     .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [4,]    .    .    . 1.33    .    .    .    .    .     .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [5,]    .    .    .    .    2    .    .    .    .     .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [6,]    .    .    .    .    .    2    .    .    .     .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [7,]    .    .    .    .    .    . 2.46    .    .     .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [8,]    .    .    .    .    .    .    . 2.46    .     .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [9,]    .    .    .    .    .    .    .    .    1     .&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [10,]    .    .    .    .    .    .    .    .    .  2.33&lt;/span&gt;
&amp;nbsp;
&lt;a href="http://inside-r.org/r-doc/base/round"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;round&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/t"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;t&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;TInv&lt;span style="color: #009900;"&gt;)&lt;/span&gt; %*% DInv %*% TInv&lt;span style="color: #339933;"&gt;,&lt;/span&gt; digits=&lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## 10 x 10 sparse Matrix of class "dgCMatrix"&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## ...&lt;/span&gt;
&lt;a href="http://inside-r.org/r-doc/base/round"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;round&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/crossprod"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;crossprod&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/sqrt"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;sqrt&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;DInv&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&amp;nbsp;%*% TInv&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; digits=&lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;## 10 x 10 sparse Matrix of class "dsCMatrix"&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;##  [1,]  1.5  0.50 -1.0  .     .     .     .     .     .     .   &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [2,]  0.5  2.33 -0.5 -0.67  .    -1.00  .     .     .     .   &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [3,] -1.0 -0.50  3.0  0.50 -1.00 -1.00  .     .     .     .   &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [4,]  .   -0.67  0.5  1.83 -1.00  .     .     .     .     .   &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [5,]  .    .    -1.0 -1.00  3.23  1.23 -1.23 -1.23  .     .   &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [6,]  .   -1.00 -1.0  .     1.23  3.23 -1.23 -1.23  .     .   &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [7,]  .    .     .    .    -1.23 -1.23  2.46  .     .     .   &lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [8,]  .    .     .    .    -1.23 -1.23  .     3.04  0.58 -1.16&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;##  [9,]  .    .     .    .     .     .     .     0.58  1.58 -1.16&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## [10,]  .    .     .    .     .     .     .    -1.16 -1.16  2.33&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;## To check&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;&lt;span class="Apple-style-span" style="color: black; font-style: normal;"&gt;solve(A) - &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;&lt;a href="http://inside-r.org/r-doc/base/crossprod"&gt;crossprod&lt;/a&gt;&lt;/span&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/sqrt"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;sqrt&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;DInv&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&amp;nbsp;%*% TInv&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
The second method (using crossprod) is preferred as it leads directly to symmetric matrix (dsCMatrix), which stores only upper or lower triangle. And make sure you do not do&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;&lt;a href="http://inside-r.org/r-doc/base/crossprod"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;crossprod&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;TInv %*%&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;&lt;a href="http://inside-r.org/r-doc/base/sqrt"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;sqrt&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;DInv&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #009900; font-family: monospace; white-space: pre;"&gt;)&lt;/span&gt;&amp;nbsp;as it is the wrong order of matrices.&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
As promised we will display (plot) pedigree by use of conversion functions of matrix objects to graph objects using the following code. Two examples are provided using the graph and igraph packages. The former does a very good job on this example, but otherwise igraph seems to have much nicer support for editing etc.&lt;/div&gt;
&lt;br /&gt;
&lt;div style="overflow: auto;"&gt;
&lt;div class="geshifilter"&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;## source("http://www.bioconductor.org/biocLite.R")&lt;/span&gt;
&lt;span style="color: #666666; font-style: italic;"&gt;## biocLite(pkgs=c("graph", "Rgraphviz"))&lt;/span&gt;
&lt;a href="http://inside-r.org/r-doc/base/library"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;library&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;package=&lt;span style="color: blue;"&gt;"graph"&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&lt;a href="http://inside-r.org/r-doc/base/library"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;library&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;package=&lt;span style="color: blue;"&gt;"Rgraphviz"&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
g &amp;lt;- &lt;a href="http://inside-r.org/r-doc/methods/as"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;as&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/t"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;t&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;TInv&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;"graph"&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
&lt;a href="http://inside-r.org/r-doc/graphics/plot"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;plot&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;g&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-Rz7LI7iH3mc/TkReX-P1jpI/AAAAAAAAAts/iXgbAstRHqM/s1600/pedDAG.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://4.bp.blogspot.com/-Rz7LI7iH3mc/TkReX-P1jpI/AAAAAAAAAts/iXgbAstRHqM/s320/pedDAG.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="overflow: auto;"&gt;
&lt;div class="geshifilter"&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;## install.packages(pkgs="igraph")&lt;/span&gt;
&lt;a href="http://inside-r.org/r-doc/base/library"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;library&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;package=&lt;span style="color: blue;"&gt;"igraph"&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
i &amp;lt;- igraph.from.graphNEL&lt;span style="color: #009900;"&gt;(&lt;/span&gt;graphNEL=g&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
V&lt;span style="color: #009900;"&gt;(&lt;/span&gt;i&lt;span style="color: #009900;"&gt;)&lt;/span&gt;$label &amp;lt;- &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;:&lt;span style="color: #cc66cc;"&gt;10&lt;/span&gt;
&lt;a href="http://inside-r.org/r-doc/graphics/plot"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;plot&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;i&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/graphics/layout"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;layout&lt;/span&gt;&lt;/a&gt;=layout.kamada.kawai&lt;span style="color: #009900;"&gt;)&lt;/span&gt;
## tkplot&lt;span style="color: #009900;"&gt;(&lt;/span&gt;i&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-W-DbP7I09lk/TkRelF5_f3I/AAAAAAAAAtw/0OiQVra5L6w/s1600/pedDAG2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="291" src="http://1.bp.blogspot.com/-W-DbP7I09lk/TkRelF5_f3I/AAAAAAAAAtw/0OiQVra5L6w/s320/pedDAG2.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #009900;"&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-5436463214104826881?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/4XBuUbNUSf8" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/4XBuUbNUSf8/setup-up-inverse-of-additive.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-Rz7LI7iH3mc/TkReX-P1jpI/AAAAAAAAAts/iXgbAstRHqM/s72-c/pedDAG.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/08/setup-up-inverse-of-additive.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-842612073548307395</guid><pubDate>Mon, 01 Aug 2011 19:27:00 +0000</pubDate><atom:updated>2011-08-01T21:52:07.831+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">genetics</category><category domain="http://www.blogger.com/atom/ns#">graphics</category><title>Kermode Bear Genetics Graphic From National Geographic Magazine</title><description>&lt;div style="text-align: justify;"&gt;Kermode bear is a black bear from British Columbia, which is not black, but white as demonstrated in this photo (linked from &lt;a href="http://ngm.nationalgeographic.com/2011/08/kermode-bear/barcott-text"&gt;National Geographic (NG) story about these bears&lt;/a&gt;). &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;a href="http://pictopia.com/perl/get_image?provider_id=318&amp;amp;ptp_photo_id=natgeo:9598053&amp;amp;size=400_art&amp;amp;m=1311782948.0" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 266px;" src="http://pictopia.com/perl/get_image?provider_id=318&amp;amp;ptp_photo_id=natgeo:9598053&amp;amp;size=400_art&amp;amp;m=1311782948.0" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The &lt;a href="http://ngm.nationalgeographic.com/2011/08/kermode-bear/barcott-text"&gt;story&lt;/a&gt; also explains the genetic mechanism behind this coloring. It is a type of &lt;a href="http://en.wikipedia.org/wiki/Recessive"&gt;autosomal recessive gene&lt;/a&gt;, where white color is seen only in animals carrying two copies of the white allele (gene type). NG story tried to demonstrate this with the following graphic (again linked from the &lt;a href="http://ngm.nationalgeographic.com/2011/08/kermode-bear/barcott-text"&gt;National Geographic (NG) story about these bears&lt;/a&gt;). However, they did one pretty annoying flaw. Why did not they draw two circles in each bear representing two gene copies each animal carries? This would be the most natural way to boost this graphics! They should have used two circles with black and white color.  Bears would be white only if they would carry two white circles and black otherwise. In addition it would be nice to add also a mating between two animals carrying each two black genes.&lt;/div&gt;&lt;a href="http://ngm.nationalgeographic.com/2011/08/kermode-bear/img/kermode-bear-genetics-500.gif" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 490px;" src="http://ngm.nationalgeographic.com/2011/08/kermode-bear/img/kermode-bear-genetics-500.gif" border="0" alt="" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-842612073548307395?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/APpg59DqK9c" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/APpg59DqK9c/kermode-bear-graphic-kermode-genetics.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/08/kermode-bear-graphic-kermode-genetics.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-358626580746156999</guid><pubDate>Mon, 18 Jul 2011 19:37:00 +0000</pubDate><atom:updated>2011-07-18T21:47:36.526+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">genetics</category><category domain="http://www.blogger.com/atom/ns#">animalScience</category><title>Genomic selection FAQ</title><description>Was compiled by &lt;a href="http://nce.ads.uga.edu/%7Eignacy/"&gt;Ignacy Misztal&lt;/a&gt; and is available &lt;a href="http://onlinelibrary.wiley.com/doi/10.1111/j.1439-0388.2011.00944.x/pdf"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-358626580746156999?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/Xnb8E13vUqA" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/Xnb8E13vUqA/genomic-selection-faq.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/07/genomic-selection-faq.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-5292618392305743059</guid><pubDate>Fri, 03 Jun 2011 12:29:00 +0000</pubDate><atom:updated>2011-06-03T14:35:46.147+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">biology</category><category domain="http://www.blogger.com/atom/ns#">computers</category><title>Agilent's  Integrated Biology Grant Program</title><description>&lt;div style="text-align: justify;"&gt;Fostering integrated, whole-systems approaches to biological research with two $75,000US grants for open source data-integration tool development. See more &lt;a href="https://www.chem.agilent.com/en-US/solutions/promotions/emerging/Pages/default.aspx?cid=4931"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-5292618392305743059?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/q1KG_hHKCN8" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/q1KG_hHKCN8/agilents-integrated-biology-grant.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/06/agilents-integrated-biology-grant.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-6080609898280786812</guid><pubDate>Mon, 18 Apr 2011 09:54:00 +0000</pubDate><atom:updated>2011-04-18T11:56:01.946+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">web</category><category domain="http://www.blogger.com/atom/ns#">LaTeX</category><title>LaTeXsearch.com</title><description>&lt;div style="text-align: justify;"&gt;Want to search over published equations? Try out &lt;a href="http://latexsearch.com"&gt;LaTeXsearch.com&lt;/a&gt;. I wonder how useful this might be in practice?&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-6080609898280786812?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/M8S9AQbGVAg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/M8S9AQbGVAg/latexsearchcom.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/04/latexsearchcom.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-7296456874419669837</guid><pubDate>Thu, 14 Apr 2011 22:33:00 +0000</pubDate><atom:updated>2011-04-15T01:24:43.618+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">genetics</category><category domain="http://www.blogger.com/atom/ns#">R</category><title>gRain: genetics example</title><description>&lt;div style="text-align: justify;"&gt;&lt;a href="http://cran.r-project.org/web/packages/gRain/"&gt;gRain&lt;/a&gt; is an R package for "probability propagation in graphical independence networks, also known as probabilistic expert systems (which includes Bayesian networks as a special case)".  This package caught my attention because some genetic models can be seen as graphical models, which is a broader class of models encompassing &lt;a href="http://en.wikipedia.org/wiki/Bayesian_network"&gt;Bayesian networks&lt;/a&gt; or sometimes also called &lt;a href="http://en.wikipedia.org/wiki/Directed_acyclic_graph"&gt;Directed Acyclic graphs (DAGs)&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;A very simple example of DAG in genetics is to draw a pedigree of a small family (say father, mother, and child) with three nodes representing their genotype (g01, g02, and g03). Nodes are logically connected, father to child (g01 --&amp;gt; g03) and mother to child (g02 --&amp;gt; g03). Assume we observe some phenotype condition in a child and if we postulate that this phenotype is affected by genotype, we draw another connection between genotype and phenotype of a child (g03 --&amp;gt; p03).&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/-gYjwoW8Js1U/Tad5iW4rmvI/AAAAAAAAAsg/GBqs01M8wrM/s1600/DAG.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 320px;" src="http://2.bp.blogspot.com/-gYjwoW8Js1U/Tad5iW4rmvI/AAAAAAAAAsg/GBqs01M8wrM/s320/DAG.png" alt="" id="BLOGGER_PHOTO_ID_5595574693196962546" border="0" /&gt;&lt;/a&gt;&lt;div style="text-align: justify;"&gt;This kind of problems/models are often postulated and one might want to do some queries about the genotype of individuals given some data (observed phenotype and/or genotype). Can we do this in R? Yes, this can be neatly done with the gRain package.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Before digging into the code we need to pause to see how can we describe the above model? If you have read at least some parts of Wikipedia links provided above than it should be straightforward to understand the following factorization of this simple model: p(g01, g02, g03, p03) = p(g01) p(g02) p(g03|g01, g02) p(p03|g03). The terms p(g01) and p(g02) are often called prior distributions (probabilities) of genotypes in some population. Term p(g03|g01, g02) describes probability of genotype in child (g03) given that we know the genotype of parents (g01 and g02). This is actually very simple part and often referred as transmission probability  If there are only two alleles (gene variants) in population (A and a)  and father is AA and mother is AA then child must also be AA or p(g03|g01=AA, g02=AA) = (1, 0, 0), where number show probability for genotype AA, Aa, and aa. The last term p(p03|g03) is often called penetrance function and tells us the conditional probability of some phenotype given the genotype data.  Let us assume that we are interested in some binary condition, which is under very very large influence of genotype, but expressed primarily in individuals with genotype aa. Bellow is R code for specifying such a model with some additional details skipped in the text.&lt;br /&gt;&lt;/div&gt;&lt;div style="overflow: auto;"&gt;&lt;div class="geshifilter"&gt;&lt;pre class="r geshifilter-R"  style="font-family:monospace;"&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;## Set of genotype values&lt;/span&gt;&lt;br /&gt;geno &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;"AA"&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;"Aa"&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;"aa"&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;## Prior allele frequencies in (founder) population&lt;/span&gt;&lt;br /&gt;PrA &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;2&lt;/span&gt;&lt;span style=""&gt;/&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;3&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;Pra &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt; &lt;span style=""&gt;-&lt;/span&gt; PrA&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;## Prior genotype frequencies in (founder) population - according to Hardy-Weinberg's law&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;gP &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;PrA&lt;span style=""&gt;*&lt;/span&gt;PrA&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;2&lt;/span&gt;&lt;span style=""&gt;*&lt;/span&gt;PrA&lt;span style=""&gt;*&lt;/span&gt;Pra&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; Pra&lt;span style=""&gt;*&lt;/span&gt;Pra&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;## Genotype frequencies in children given the genotype of parents - according to Mendel's law &lt;/span&gt;&lt;br /&gt;gM_AA_AA &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;  &lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt;   &lt;span style="color: rgb(204, 102, 204);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt;   &lt;span style="color: rgb(204, 102, 204);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;gM_AA_Aa &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style=""&gt;/&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style=""&gt;/&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt;   &lt;span style="color: rgb(204, 102, 204);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;gM_AA_aa &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;  &lt;span style="color: rgb(204, 102, 204);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt;   &lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt;   &lt;span style="color: rgb(204, 102, 204);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;gM_Aa_AA &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style=""&gt;/&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style=""&gt;/&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt;   &lt;span style="color: rgb(204, 102, 204);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;gM_Aa_Aa &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style=""&gt;/&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;4&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style=""&gt;/&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style=""&gt;/&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;4&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;gM_Aa_aa &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;  &lt;span style="color: rgb(204, 102, 204);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style=""&gt;/&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style=""&gt;/&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;gM_aa_AA &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;  &lt;span style="color: rgb(204, 102, 204);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt;   &lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt;   &lt;span style="color: rgb(204, 102, 204);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;gM_aa_Aa &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;  &lt;span style="color: rgb(204, 102, 204);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style=""&gt;/&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style=""&gt;/&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;gM_aa_aa &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;  &lt;span style="color: rgb(204, 102, 204);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt;   &lt;span style="color: rgb(204, 102, 204);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt;   &lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;gM &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;gM_AA_AA&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; gM_AA_Aa&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; gM_AA_aa&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt;&lt;br /&gt;gM_Aa_AA&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; gM_Aa_Aa&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; gM_Aa_aa&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt;&lt;br /&gt;gM_aa_AA&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; gM_aa_Aa&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; gM_aa_aa&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;## Set of phenotype values&lt;/span&gt;&lt;br /&gt;phen &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;"OK"&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;"NOK"&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;## Error rate (= 1 - penetrance)&lt;/span&gt;&lt;br /&gt;e &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;0.01&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;## Phenotype frequencies in individual given the genotype of individual - penetrance&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;##      OK  NOK&lt;/span&gt;&lt;br /&gt;p &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style=""&gt;-&lt;/span&gt;e&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;0&lt;/span&gt;&lt;span style=""&gt;+&lt;/span&gt;e&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;## AA&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style=""&gt;-&lt;/span&gt;e&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;0&lt;/span&gt;&lt;span style=""&gt;+&lt;/span&gt;e&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;## Aa&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;0&lt;/span&gt;&lt;span style=""&gt;+&lt;/span&gt;e&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style=""&gt;-&lt;/span&gt;e&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;## aa&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;## Graph - joint distribution&lt;/span&gt;&lt;br /&gt;g01 &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; cptable&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;&lt;span style=""&gt;~&lt;/span&gt;g01&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt;             values=gP&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/levels"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;levels&lt;/span&gt;&lt;/a&gt;=geno&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;g02 &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; cptable&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;&lt;span style=""&gt;~&lt;/span&gt;g02&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt;             values=gP&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/levels"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;levels&lt;/span&gt;&lt;/a&gt;=geno&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;g03 &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; cptable&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;&lt;span style=""&gt;~&lt;/span&gt;g03 &lt;span style=""&gt;+&lt;/span&gt; g01 &lt;span style=""&gt;+&lt;/span&gt; g02&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; values=gM&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/levels"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;levels&lt;/span&gt;&lt;/a&gt;=geno&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;p03 &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; cptable&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;&lt;span style=""&gt;~&lt;/span&gt;p03 &lt;span style=""&gt;+&lt;/span&gt; g03&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt;       values=p&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt;  &lt;a href="http://inside-r.org/r-doc/base/levels"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;levels&lt;/span&gt;&lt;/a&gt;=phen&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;## Compile model&lt;/span&gt;&lt;br /&gt;plist &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; compileCPT&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/list"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;list&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;g01&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; g02&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; g03&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; p03&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;g &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/packages/cran/gRain"&gt;&lt;span style=""&gt;grain&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;plist&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;a href="http://inside-r.org/r-doc/base/summary"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;summary&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;g&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;## Plot the model&lt;/span&gt;&lt;br /&gt;iplot&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;g&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Now if we want to query our model without any observed data, but just using parameter values for this population we use the following code:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="overflow: auto;"&gt;&lt;div class="geshifilter"&gt;&lt;pre class="r geshifilter-R"  style="font-family:monospace;"&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;## Query model given parameter values (=prior)&lt;/span&gt;&lt;br /&gt;querygrain&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;g&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; nodes=&lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;"g01"&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;"g02"&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;"g03"&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;which returns probabilities shown bellow. Not really interesting, but we should not expect much as we did not observe any data. Genotype probabilities are equal for all individuals and they are completely defined by population parameters.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="overflow: auto;"&gt;&lt;div class="geshifilter"&gt;&lt;pre class="r geshifilter-R"  style="font-family:monospace;"&gt;&lt;span style=""&gt;$&lt;/span&gt;g01&lt;br /&gt;g01&lt;br /&gt;   AA        Aa        aa&lt;br /&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;0.4444444&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;0.4444444&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;0.1111111&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;$&lt;/span&gt;g02&lt;br /&gt;g02&lt;br /&gt;   AA        Aa        aa&lt;br /&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;0.4444444&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;0.4444444&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;0.1111111&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;$&lt;/span&gt;g03&lt;br /&gt;g03&lt;br /&gt;   AA        Aa        aa&lt;br /&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;0.4444444&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;0.4444444&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;0.1111111&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Now we can add some data and repeat the query again.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="overflow: auto;"&gt;&lt;div class="geshifilter"&gt;&lt;pre class="r geshifilter-R"  style="font-family:monospace;"&gt;g &lt;span style=""&gt;&amp;lt;-&lt;/span&gt; setFinding&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;g&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; nodes=&lt;span style="color: rgb(0, 0, 255);"&gt;"p03"&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; states=&lt;span style="color: rgb(0, 0, 255);"&gt;"NOK"&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;a href="http://inside-r.org/r-doc/base/summary"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;summary&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;g&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102); font-style: italic;"&gt;## Query model given parameter values (=prior) + some data&lt;/span&gt;&lt;br /&gt;querygrain&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;g&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; nodes=&lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;"g01"&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;"g02"&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;"g03"&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Results show probability of such finding (that phenotype condition was observed) given the defined model and parameters. Probability is not really high. Further on we get updated genotype probabilities and we can see the change due to introduction of phenotype information. Now we can claim with high confidence that child has genotype aa, while there is still quite some ambiguity about genotypes of parents as there are several possible combinations of parent genotypes that would give aa genotype in child (Aa x Aa, Aa x aa, aa x Aa, and aa x aa).&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="overflow: auto;"&gt;&lt;div class="geshifilter"&gt;&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;Independence &lt;a href="http://inside-r.org/packages/cran/network"&gt;&lt;span style=""&gt;network&lt;/span&gt;&lt;/a&gt;&lt;span style=""&gt;:&lt;/span&gt; Compiled&lt;span style=""&gt;:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0); font-weight: bold;"&gt;TRUE&lt;/span&gt; Propagated&lt;span style=""&gt;:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0); font-weight: bold;"&gt;TRUE&lt;/span&gt;&lt;br /&gt;Nodes &lt;span style=""&gt;:&lt;/span&gt; chr &lt;span style="color: rgb(0, 153, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style=""&gt;:&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;4&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;]&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;"g01"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;"g02"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;"g03"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;"p03"&lt;/span&gt;&lt;br /&gt;Number of cliques&lt;span style=""&gt;:&lt;/span&gt;                 &lt;span style="color: rgb(204, 102, 204);"&gt;2&lt;/span&gt;&lt;br /&gt;Maximal clique size&lt;span style=""&gt;:&lt;/span&gt;               &lt;span style="color: rgb(204, 102, 204);"&gt;3&lt;/span&gt;&lt;br /&gt;Maximal &lt;a href="http://inside-r.org/r-doc/datasets/state"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;state&lt;/span&gt;&lt;/a&gt; &lt;a href="http://inside-r.org/packages/cran/space"&gt;&lt;span style=""&gt;space&lt;/span&gt;&lt;/a&gt; &lt;span style="color: rgb(0, 0, 0); font-weight: bold;"&gt;in&lt;/span&gt; cliques&lt;span style=""&gt;:&lt;/span&gt;   &lt;span style="color: rgb(204, 102, 204);"&gt;27&lt;/span&gt;&lt;br /&gt;Finding&lt;span style=""&gt;:&lt;/span&gt;&lt;br /&gt;   variable &lt;a href="http://inside-r.org/r-doc/datasets/state"&gt;&lt;span style="color: rgb(0, 51, 153); font-weight: bold;"&gt;state&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(51, 153, 51);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;]&lt;/span&gt; p03      NOK&lt;br /&gt;Pr&lt;span style="color: rgb(0, 153, 0);"&gt;(&lt;/span&gt;Finding&lt;span style="color: rgb(0, 153, 0);"&gt;)&lt;/span&gt;= &lt;span style="color: rgb(204, 102, 204);"&gt;0.1188889&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;$&lt;/span&gt;g01&lt;br /&gt;g01&lt;br /&gt;      AA         Aa         aa&lt;br /&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;0.03738318&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;0.64797508&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;0.31464174&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;$&lt;/span&gt;g02&lt;br /&gt;g02&lt;br /&gt;      AA         Aa         aa&lt;br /&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;0.03738318&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;0.64797508&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;0.31464174&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;$&lt;/span&gt;g03&lt;br /&gt;g03&lt;br /&gt;      AA         Aa         aa&lt;br /&gt;&lt;span style="color: rgb(204, 102, 204);"&gt;0.03738318&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;0.03738318&lt;/span&gt; &lt;span style="color: rgb(204, 102, 204);"&gt;0.92523364&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;This is all for the purpose of this blog post, but it should be clear that it is very easy to extend our model either with model individuals (just defined them with cptable and compile in joint model) or with other stuff (more alleles leads to more genotypes, other penetrance function, sex-linked genes, ...).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-7296456874419669837?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/FT34Y9blZuM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/FT34Y9blZuM/grain-genetics-example.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-gYjwoW8Js1U/Tad5iW4rmvI/AAAAAAAAAsg/GBqs01M8wrM/s72-c/DAG.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/04/grain-genetics-example.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-576684352235741758</guid><pubDate>Fri, 01 Apr 2011 07:23:00 +0000</pubDate><atom:updated>2011-04-01T09:37:19.391+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">computers</category><category domain="http://www.blogger.com/atom/ns#">linux</category><title>Redish color of screen for evening or night work</title><description>&lt;div style="text-align: justify;"&gt;While reading local computer magazine (&lt;a href="http://www.monitor.si/"&gt;Monitor&lt;/a&gt;) I find out about &lt;a href="http://stereopsis.com/flux"&gt;f.lux&lt;/a&gt;, which is program that changes the color of screen to more redish for evening or night work. They claim that this protects our eyes and sleep pattern. I like the idea. Linux support has some problems, but their is alternative that works with Linux - &lt;a href="http://jonls.dk/redshift/"&gt;redshift&lt;/a&gt; (see &lt;a href="http://jonls.dk/redshift/"&gt;here&lt;/a&gt; and &lt;a href="http://www.makeuseof.com/tag/redshift-eyes-sharp-helps-sleep-linux/"&gt;here&lt;/a&gt; for installation).&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-576684352235741758?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/Ib4zjoMeHl0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/Ib4zjoMeHl0/redish-color-of-screen-for-evening-or.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/04/redish-color-of-screen-for-evening-or.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-4746478353517569489</guid><pubDate>Fri, 01 Apr 2011 07:11:00 +0000</pubDate><atom:updated>2011-04-01T09:20:41.373+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">web</category><title>Different view options for my blog</title><description>&lt;div style="text-align: justify;"&gt;Blogger now offers several &lt;a href="http://www.google.com/support/blogger/bin/answer.py?hl=en&amp;amp;answer=1229061&amp;amp;ctx=go"&gt;dynamic views&lt;/a&gt; for public blogs. Click on the following links to see them in action for my blog:&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://ggorjan.blogspot.com/view/flipcard"&gt;Flipcard&lt;/a&gt; (quite good overview of posts - reminds me of the memory game where cards are flipped to find a pair)&lt;/li&gt;&lt;li&gt;&lt;a href="http://ggorjan.blogspot.com/view/mosaic"&gt;Mosaic&lt;/a&gt; (similar as &lt;a href="http://ggorjan.blogspot.com/view/flipcard"&gt;Flipcard&lt;/a&gt;, but cards have different sizes)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://ggorjan.blogspot.com/view/sidebar"&gt;Sidebar&lt;/a&gt; (more or less like standard view, but with bar on the left side)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://ggorjan.blogspot.com/view/snapshot"&gt;Snapshot&lt;/a&gt; (shows only preview-snapshots of posts with images stored in Picasa and linked with Blogger)&lt;/li&gt;&lt;li&gt;&lt;a href="http://ggorjan.blogspot.com/view/timeslide"&gt;Timeslide&lt;/a&gt; (a bit confused layout by time)&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;In my view these are cool views, but the &lt;a href="http://www.google.com/support/blogger/bin/answer.py?hl=en&amp;amp;answer=1229061&amp;amp;ctx=go"&gt;help page&lt;/a&gt; is much nicer due to use of graphics. If you do not have much graphics in your posts you will not be that much impressed.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-4746478353517569489?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/l8eZBTChwU8" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/l8eZBTChwU8/different-view-options-for-my-blog.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/04/different-view-options-for-my-blog.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-8220233577992006088</guid><pubDate>Wed, 30 Mar 2011 21:45:00 +0000</pubDate><atom:updated>2011-03-31T00:37:41.945+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">graphics</category><title>Plot large networks</title><description>&lt;div style="text-align: justify;"&gt;After fiding out &lt;a href="http://ggorjan.blogspot.com/2011/03/exploring-graphs-with-gephi.html"&gt;Gephi&lt;/a&gt; I came across &lt;a href="http://mkweb.bcgsc.ca/linnet/"&gt;hive plots&lt;/a&gt;, which seem to be genuine way to plot large networks with information gain in mind. The tool is called linnet, which probably relates to "linearizing the network" and was developed in the group of Martin Krzywinski. Bellow is a plot from their webpage, while you can find more detailes in talks and posters that are linked on their website. Cool stuff indeed!!! They also have a tool called &lt;a href="http://mkweb.bcgsc.ca/tableviewer/visualize"&gt;circo&lt;/a&gt; for circular display of relations among many nodes, something like correlations.&lt;/div&gt;&lt;br /&gt;&lt;a href="http://mkweb.bcgsc.ca/linnet/img/web-title.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 600px; height: 450px;" src="http://mkweb.bcgsc.ca/linnet/img/web-title.png" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://mkweb.bcgsc.ca/tableviewer//img/data-vis.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 350px; height: 707px;" src="http://mkweb.bcgsc.ca/tableviewer//img/data-vis.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-8220233577992006088?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/f4-XlO263Qg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/f4-XlO263Qg/plot-large-networks.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>1</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/03/plot-large-networks.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-7298876535708436528</guid><pubDate>Thu, 17 Mar 2011 10:01:00 +0000</pubDate><atom:updated>2011-03-17T11:02:24.651+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">genetics</category><category domain="http://www.blogger.com/atom/ns#">graphics</category><title>Exploring graphs with Gephi</title><description>This tool (&lt;a href="http://gephi.org/"&gt;Gephi&lt;/a&gt;) looks awesome. See it in action at &lt;a href="http://diseasome.eu/map.html#"&gt;Diseasome&lt;/a&gt;!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-7298876535708436528?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/pxekAsA8TCE" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/pxekAsA8TCE/exploring-graphs-with-gephi.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/03/exploring-graphs-with-gephi.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-5499381698176412276</guid><pubDate>Tue, 15 Mar 2011 22:32:00 +0000</pubDate><atom:updated>2011-03-15T23:34:20.609+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">computers</category><category domain="http://www.blogger.com/atom/ns#">linux</category><category domain="http://www.blogger.com/atom/ns#">R</category><title>Nice simple notes on running R in parallel by Geyer</title><description>&lt;a href="http://www.stat.umn.edu/~charlie/parallel/"&gt;Here&lt;/a&gt;, by Charles J. Geyer.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-5499381698176412276?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/af5XdNwK7rU" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/af5XdNwK7rU/nice-simple-notes-on-running-r-in.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/03/nice-simple-notes-on-running-r-in.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-8833795442557859865</guid><pubDate>Tue, 15 Mar 2011 09:02:00 +0000</pubDate><atom:updated>2011-03-15T10:04:37.088+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">video</category><category domain="http://www.blogger.com/atom/ns#">genetics</category><category domain="http://www.blogger.com/atom/ns#">animalScience</category><title>AB Chapman Lectures</title><description>&lt;div style="text-align: justify;"&gt;There is a nice set of videos on animal breeding and genetics topics from the AB Chapman Lectures series available at the &lt;a href="http://www.ansci.wisc.edu/chapman/index.htm"&gt;University of Wisconsin site&lt;/a&gt;. This is now also included in the &lt;a href="http://www.netvibes.com/ABG-Hub"&gt;ABG-Hub site&lt;/a&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-8833795442557859865?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/S7B1TKaek6s" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/S7B1TKaek6s/ab-chapman-lectures.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/03/ab-chapman-lectures.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-4268312710209464199</guid><pubDate>Fri, 04 Mar 2011 00:53:00 +0000</pubDate><atom:updated>2011-03-04T02:05:47.679+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">statistics</category><category domain="http://www.blogger.com/atom/ns#">si</category><title>Prevod: Bayesian statistics in Bayesian updating</title><description>&lt;div style="text-align: justify;"&gt;Prevajanje strokovnih izrazov iz tujega jezika (primarno angleščine) v slovenski jezik je zadeva, ki je ne maram. Najbrž iz razloga, da nisem ravno ne vem kako "dober v slovenščini". Poleg tega je prevajanje zamudna reč in vsak ima svojo varianto prevoda. Pred nekaj leti sem ob druženju s študenti statistike predstavil "&lt;a href="http://www.scribd.com/doc/3901893/Uvod-v-Bayesovsko-Statistiko"&gt;Bayesian statistics&lt;/a&gt;". Takrat smo se ubadali glede prevoda in prišli do sklepa, da je "&lt;b&gt;Bayesovska statistika&lt;/b&gt;" primeren prevod in ne "&lt;b&gt;Bayesova statistika&lt;/b&gt;". Danes sem bil ponovno vključen v podobno "debato", kjer smo prevedli "&lt;b&gt;Bayesian updating&lt;/b&gt;" v "&lt;b&gt;Bayesovsko posodabljanje&lt;/b&gt;". Pomen tega izraza tiči v tem, da lahko pri Bayesovski statistiki rezultat (posteriorna porazdelitev) iz ene analize uporabimo kot predhodno znanje/vedenje (apriorno porazdelitev) pri drugi/novi analizi. Ima mogoče kdo kakšen boljši predlog prevoda?&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-4268312710209464199?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/mEuBDmazTUY" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/mEuBDmazTUY/prevod-bayesian-statistics-in-bayesian.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/03/prevod-bayesian-statistics-in-bayesian.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-8358972804275934055</guid><pubDate>Thu, 03 Mar 2011 10:56:00 +0000</pubDate><atom:updated>2011-03-13T12:21:53.572+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">genetics</category><category domain="http://www.blogger.com/atom/ns#">study</category><category domain="http://www.blogger.com/atom/ns#">animalScience</category><category domain="http://www.blogger.com/atom/ns#">web</category><title>ABG-HUB - Animal Breeding and Genetics Hub</title><description>&lt;a href="http://gbaor.blogspot.com/"&gt;Gabor Meszaros&lt;/a&gt; sent out today this message&lt;br /&gt;&lt;div&gt;&lt;blockquote&gt;Dear colleagues,&lt;br /&gt;&lt;br /&gt;I would like to officially announce the website “Animal Breeding and Genetics Hub” we created with Gregor Gorjanc (Slovenia). The site supposed to serve as a place holding links to free animal breeding relatedsites throughout the Web.&lt;br /&gt;&lt;br /&gt;At this point we have links to some online course materials,conference proceedings, links to ABG software sites, mailing lists, biodiversity and agricultural development resources. We also make use of the Web 2.0features such as RSS feeds, which show you the links to papers from various scientific journals in real time on one page meaning that if anew paper comesout it shows up in the RSS feed). Also there are some pictures and videos fromsome organizations, and more…&lt;br /&gt;&lt;br /&gt;The link to the website is: &lt;a href="http://www.netvibes.com/ABG-Hub#General"&gt;http://www.netvibes.com/ABG-Hub#General&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;We tried to include most of our links to have some contentright at the start. But it is likely that we missed some good resources/journals out there. We would like to ask you that if you know about something that is not yet on the site, please let us know via the email: ABGHub@gmail.com&lt;br /&gt;&lt;br /&gt;Also we would be happy to get any kind of feedback on ourwork.&lt;/blockquote&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-8358972804275934055?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/cY6fGUlxt-s" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/cY6fGUlxt-s/agb-hub-animal-breeding-and-genetics.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/03/agb-hub-animal-breeding-and-genetics.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-3177342822285416544</guid><pubDate>Thu, 17 Feb 2011 19:12:00 +0000</pubDate><atom:updated>2011-02-17T20:14:37.300+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">study</category><title>onlinecourses.net</title><description>&lt;div style="text-align: justify;"&gt;The website &lt;a href="http://www.onlinecourses.net/"&gt;http://www.onlinecourses.net/&lt;/a&gt; offers a nice index to online courses. &lt;a href="http://www.onlinecourses.net/free-online-courses"&gt;The section with free courses&lt;/a&gt; is particularly rich.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Claim: I was asked to spread the word about this website and I believe it is worth doing it;)&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-3177342822285416544?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/oh7bEVJDHL0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/oh7bEVJDHL0/onlinecoursesnet.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/02/onlinecoursesnet.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-9085780618998568774</guid><pubDate>Fri, 04 Feb 2011 20:35:00 +0000</pubDate><atom:updated>2011-02-05T14:06:29.724+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">statistics</category><category domain="http://www.blogger.com/atom/ns#">genetics</category><category domain="http://www.blogger.com/atom/ns#">animalScience</category><category domain="http://www.blogger.com/atom/ns#">talks</category><category domain="http://www.blogger.com/atom/ns#">INLA</category><category domain="http://www.blogger.com/atom/ns#">cattle</category><title>Use of INLA for animal breeding applications</title><description>&lt;div style="text-align: justify;"&gt;I am working with &lt;a href="http://www.math.ntnu.no/~ingelins"&gt;Ingelin Steinsland&lt;/a&gt; and &lt;a href="http://www.math.ntnu.no/~martino"&gt;Sara Martino&lt;/a&gt; on the use of approximate Bayesian method called &lt;a href="http://www.r-inla.org/"&gt;Integrated Nested Laplace Approximation (INLA)&lt;/a&gt;. We presented some of our preliminary results at &lt;a href="http://www.math.uzh.ch/index.php?konferenzdetails0&amp;amp;key1=215&amp;amp;L=1"&gt;Workshop in Bayesian Inference for Latent Gaussian Models with Applications&lt;/a&gt; in Zurich (Switzerland). We had two contributions:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.scribd.com/doc/48179553"&gt;Application of Integrated Nested Laplace Approximation to Survival Models as used in Animal Breeding&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.scribd.com/doc/48179756"&gt;Use of Integrated Nested Laplace Approximation for Pedigree Based Mixed Models&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-9085780618998568774?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/OuV4KQRTliw" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/OuV4KQRTliw/use-of-inla-for-animal-breeding.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>0</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/02/use-of-inla-for-animal-breeding.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6715598735361401237.post-437191831936008941</guid><pubDate>Fri, 28 Jan 2011 17:44:00 +0000</pubDate><atom:updated>2011-01-28T23:53:44.007+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">R</category><title>Converting strsplit() output to a data.frame</title><description>&lt;div style="text-align: justify;"&gt;&lt;a href="http://www.r-project.org/"&gt;R&lt;/a&gt; has a nice set of utilities to work with strings. Function &lt;span class="Apple-style-span" style="font-family: 'courier new'; "&gt;paste&lt;/span&gt; is surely one among these. It can be used to "glue" several strings with optional separator. The following example shows how &lt;span class="Apple-style-span" style="font-family: 'courier new'; "&gt;paste&lt;/span&gt; can be used to create a new variable in a dataset:&lt;/div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new'; "&gt;&lt;blockquote&gt;&lt;pre&gt;dat &lt;- data.frame(x=1:5, y=letters[1:5])&lt;/pre&gt;&lt;pre&gt;(dat$z &lt;- with(dat, paste(x, y, sep="-")))&lt;/pre&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;Today I was in a situation where I only had column z and wanted to reverse the action of paste. Is there a way to do it? Not directly (AFAIK), but &lt;span class="Apple-style-span" style="font-family: 'courier new'; "&gt;strsplit&lt;/span&gt; seems to be quite useful for this:&lt;/div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new'; "&gt;&lt;blockquote&gt;&lt;pre&gt;(tmp &lt;- strsplit(x=dat$z, split="-"))&lt;/pre&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;However, the output of &lt;span class="Apple-style-span" style="font-family: 'courier new'; "&gt;strsplit&lt;/span&gt; is a list object with elements (vectors) by the elements of my column z and not by split components. Consequently one can not convert strsplit output easily back to a data.frame as you can test yourself with:&lt;/div&gt;&lt;meta equiv="content-type" content="text/html; charset=utf-8"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new'; "&gt;&lt;blockquote&gt;&lt;pre&gt;as.data.frame(tmp)&lt;/pre&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;Argh. I understand that &lt;span class="Apple-style-span" style="font-family: 'courier new'; "&gt;strsplit&lt;/span&gt; is meant to be very general (say we could have unequal number of components in one element, e.g., &lt;span class="Apple-style-span" style="font-family: 'courier new'; "&gt;c("1-a-0", "1-a")&lt;/span&gt;), but its output is really inconvenient for transformation to a data.frame. I came up with the following solution, which seems to work nicely and is quite fast.&lt;/div&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new'; "&gt;&lt;blockquote&gt;&lt;pre&gt;tmp &lt;- unlist(strsplit(dat$z, split="-"))&lt;/pre&gt;&lt;pre&gt;cols &lt;- c("x2", "y2")&lt;/pre&gt;&lt;pre&gt;nC &lt;- length(cols)&lt;/pre&gt;&lt;pre&gt;ind &lt;- seq(from=1, by=nC, length=nrow(dat))&lt;/pre&gt;&lt;pre&gt;for(i in 1:nC) {&lt;/pre&gt;&lt;pre&gt;  dat[, cols[i]] &lt;- tmp[ind + i - 1]&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div&gt;Does anyone have a better (more obvious) solution?&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6715598735361401237-437191831936008941?l=ggorjan.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/GregorGorjancsBlog/~4/pWfNsNI7M0Q" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/GregorGorjancsBlog/~3/pWfNsNI7M0Q/converting-strsplit-output-to-dataframe.html</link><author>noreply@blogger.com (Gregor Gorjanc)</author><thr:total>15</thr:total><feedburner:origLink>http://ggorjan.blogspot.com/2011/01/converting-strsplit-output-to-dataframe.html</feedburner:origLink></item></channel></rss>

