<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>生信菜鸟团 &#187; AnnDbBimap</title>
	<atom:link href="http://www.bio-info-trainee.com/tag/anndbbimap/feed" rel="self" type="application/rss+xml" />
	<link>http://www.bio-info-trainee.com</link>
	<description>欢迎去论坛biotrainee.com留言参与讨论，或者关注同名微信公众号biotrainee</description>
	<lastBuildDate>Sat, 28 Jun 2025 14:30:13 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.33</generator>
	<item>
		<title>R里面list对象和AnnDbBimap对象区别</title>
		<link>http://www.bio-info-trainee.com/1093.html</link>
		<comments>http://www.bio-info-trainee.com/1093.html#comments</comments>
		<pubDate>Fri, 30 Oct 2015 07:36:59 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[AnnDbBimap]]></category>
		<category><![CDATA[bioconductor]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1093</guid>
		<description><![CDATA[AnnDbBimap对象是R里面的bioconductor系列包的基础对象，在探 &#8230; <a href="http://www.bio-info-trainee.com/1093.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>AnnDbBimap对象是R里面的bioconductor系列包的基础对象，在探针数据里面会包装成ProbeAnnDbMap，跟go通路相关又是GOTermsAnnDbBimap对象。</p>
<p>但是它都是AnnDbBimap对象衍生过来的</p>
<p>主要存在于芯片系列的包和org系列的包，其实AnnDbBimap对象就是list对象的包装，比如下面这些例子：</p>
<p><strong>ls("package:hgu133plus2.db")</strong></p>
<table width="100%">
<tbody>
<tr>
<td width="100%"> [1] "hgu133plus2"              "hgu133plus2.db"           "hgu133plus2_dbconn"</td>
</tr>
<tr>
<td width="100%"> [4] "hgu133plus2_dbfile"       "hgu133plus2_dbInfo"       "hgu133plus2_dbschema"</td>
</tr>
<tr>
<td width="100%"> [7] "hgu133plus2ACCNUM"        "hgu133plus2ALIAS2PROBE"   "hgu133plus2CHR"</td>
</tr>
<tr>
<td width="100%">[10] "hgu133plus2CHRLENGTHS"    "hgu133plus2CHRLOC"        "hgu133plus2CHRLOCEND"</td>
</tr>
<tr>
<td width="100%">[13] "hgu133plus2ENSEMBL"       "hgu133plus2ENSEMBL2PROBE" "hgu133plus2ENTREZID"</td>
</tr>
<tr>
<td width="100%">[16] "hgu133plus2ENZYME"        "hgu133plus2ENZYME2PROBE"  "hgu133plus2GENENAME"</td>
</tr>
<tr>
<td width="100%">[19] "hgu133plus2GO"            "hgu133plus2GO2ALLPROBES"  "hgu133plus2GO2PROBE"</td>
</tr>
<tr>
<td width="100%">[22] "hgu133plus2MAP"           "hgu133plus2MAPCOUNTS"     "hgu133plus2OMIM"</td>
</tr>
<tr>
<td width="100%">[25] "hgu133plus2ORGANISM"      "hgu133plus2ORGPKG"        "hgu133plus2PATH"</td>
</tr>
<tr>
<td width="100%">[28] "hgu133plus2PATH2PROBE"    "hgu133plus2PFAM"          "hgu133plus2PMID"</td>
</tr>
<tr>
<td width="100%">[31] "hgu133plus2PMID2PROBE"    "hgu133plus2PROSITE"       "hgu133plus2REFSEQ"</td>
</tr>
<tr>
<td width="100%">[34] "hgu133plus2SYMBOL"        "hgu133plus2UNIGENE"       "hgu133plus2UNIPROT"</td>
</tr>
</tbody>
</table>
<p>那么我们可以随便挑选包中的一个数据分析一下</p>
<p>x &lt;- hgu133plus2SYMBOL</p>
<p>xlist=as.list(x)</p>
<p>我们查看X对象，可知，它是object of class "ProbeAnnDbMap"，而这个对象，就是常见的list对象，被包装了一下， 只有我们明白了它和list对象到底有什么区别，才算是真正搞懂了这一系列包</p>
<p>但是这个ProbeAnnDbMap对象，在GO等包里面会被包装成更复杂的对象-GOTermsAnnDbBimap，但是对他们的理解都大同小异。</p>
<p><strong>我们先回顾一下在R</strong><strong>语言里面的list</strong><strong>的基础知识：</strong></p>
<p>R 的 列表（list）是一个以对象的有序集合构成的对象。 列表中包含的对象又称为它的分量（components）。</p>
<p>分量可以是不同的模式或者类型， 如一个列表可以包括数值向量，逻辑向量，矩阵，复向量， 字符数组，函数等等</p>
<p>如果你会perl的话，可以把它理解成hash。</p>
<p>分量常常会被编号的（numbered），并且可以利用它来 访问分量</p>
<p>列表的分量可以被命名，这种情况下 可以通过名字访问。</p>
<p>特别要注意一下 Lst[[1]] 和 Lst[1] 的差别。 [[...]] 是用来选择单个 元素的操作符，而 [...] 是一个更为一般 的下标操作符。</p>
<p>因此前者得到的是列表 Lst 中的第一个对象, 并且含有分量名字的命名列表（named list）中分量的名字会被排除在外的。</p>
<p>后者得到的则是列表 Lst 中仅仅由第一个元素 构成的子列表。如果是命名列表， 分量名字会传给子列表的。</p>
<p><strong>那么接下来我们就看看x</strong><strong>和xlist</strong><strong>的区别。</strong></p>
<p>它们里面的数据都是affymetrix公司出品的人类的hgu133plus2芯片的探针ID与基因symbol的对应关系</p>
<p>如果我想拿到所有的探针ID，那么对于AnnDbBimap对象，需要用mappedkeys(x)，对于普通的list对象，需要用names(xlist).</p>
<p>对于普通的list对象，如果我想看前几个元素，直接head就可以了，但是对于AnnDbBimap对象，数据被封装好了，需要先as.list，然后才能head</p>
<p>mapped_probes &lt;- mappedkeys(x)</p>
<p>PID2=head(mapped_probes)</p>
<p>那么，如果我们想根据以下探针ID来查看它们在这些数据里面被对应着哪些基因symbol 呢？</p>
<p>&gt; PID2 #这是一串探针ID，后面的操作都需要用的</p>
<p>[1] "1053_at"   "117_at"    "121_at"    "1255_g_at" "1316_at"   "1320_at"</p>
<p>如果是对于AnnDbBimap对象，我们可以用mget函数来操作，取多个探针的对应基因symbol</p>
<p>accnum &lt;- mget(PID2, env=hgu133plus2ACCNUM);</p>
<p>gname &lt;- mget(PID2, env=hgu133plus2GENENAME)</p>
<p>gsymbol &lt;- mget(PID2, env=hgu133plus2SYMBOL)</p>
<p>mget函数返回的就是普通的list函数了，可以直接查看了。</p>
<p>如果是对于普通的list对象，我们想取多个探针的对应基因symbol也是非常简单的，xlist[PID2]即可。</p>
<p>那么我们不禁有问了，既然它们两个功能完全一样，何苦把它包装成一个对象了，我直接操作list对象不就好了，学那么多规矩干嘛？</p>
<p>所以，重点就来了</p>
<p>&gt;  length(mapped_probes)</p>
<p>[1] 42125</p>
<p>&gt; length(names(xlist))</p>
<p>[1] 54675</p>
<p>看懂了吗？</p>
<p>&nbsp;</p>
<p>但是，事实上用处也不大，你觉得下面这两个有区别吗？</p>
<p>SYMBOL &lt;- AnnotationDbi::as.list(hgu133plus2SYMBOL)</p>
<p>SYMBOL &lt;- SYMBOL[!is.na(SYMBOL)];</p>
<p>&nbsp;</p>
<p>x &lt;- hgu133plus2SYMBOL</p>
<p>mapped_probes &lt;- mappedkeys(x)</p>
<p>SYMBOL &lt;- AnnotationDbi::as.list(x[mapped_probes])</p>
<p>&nbsp;</p>
<p>PS，在R里面创建一个list对象是非常简单的</p>
<p>The <code>setNames()</code> built-in function makes it easy to create a hash from given key and value lists.<em>(Thanks to Nick K for the better suggestion.)</em></p>
<p>Usage: <code>hh &lt;- setNames(as.list(values), keys)</code></p>
<p>Example:</p>
<p>players &lt;- c("bob", "tom", "tim", "tony", "tiny", "hubert", "herbert")<br />
rankings &lt;- c(0.2027, 0.2187, 0.0378, 0.3334, 0.0161, 0.0555, 0.1357)<br />
league &lt;- setNames(as.list(rankings), players)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1093.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
