找回密码
 注册
查看: 481|回复: 0

R语言 IRanges包 Ranges-class()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-25 22:30:05 | 显示全部楼层 |阅读模式
Ranges-class(IRanges)
Ranges-class()所属R语言包:IRanges

                                        Ranges objects
                                         范围对象

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

The Ranges virtual class is a general container for storing a set of integer ranges.
范围虚拟类是一个用于存储一组整数的范围一般容器。


Details

详情----------Details----------

A Ranges object is a vector-like object where each element describes a "range of integer values".
一个范围对象是矢量对象,其中每个元素描述了一个“整数范围内”。

A "range of integer values" is a finite set of consecutive integer values. Each range can be fully described with exactly 2 integer values which can be arbitrarily picked up among the 3 following values: its "start" i.e. its smallest (or first, or leftmost) value; its "end" i.e. its greatest (or last, or rightmost) value; and its "width" i.e. the number of integer values in the range. For example the set of integer values that are greater than or equal to -20 and less than or equal to 400 is the range that starts at -20 and has a width of 421. In other words, a range is a closed, one-dimensional interval with integer end points and on the domain of integers.
一个“整数范围内”是一个连续的整数值的有限集合。每个范围可以充分说明,只有2个可以任意挑选3以下值之间的整数值:“开始”,即最小(或先,或最左边)的价值,其“结束”,即它的最大(或最后,或最右边)值,而且它的“宽度”,即整数值范围内的数字。例如,整数的值大于或等于-20,小于或等于400集-20的范围内开始有一个421的宽度。换句话说,一个范围是一个封闭的,一维的整数终点和整数域上的间隔。

The starting point (or "start") of a range can be any integer (see start below) but its "width" must be a non-negative integer (see width below). The ending point (or "end") of a range is equal to its "start" plus its "width" minus one (see end below). An "empty" range is a range that contains no value i.e. a range that has a null width. Depending on the context, it can be interpreted either as just the empty set of integers or, more precisely, as the position between its "end" and its "start" (note that for an empty range, the "end" equals the "start" minus one).
起点(或“开始”)的范围可以是任何整数(见start以下),但它的“宽度”必须是一个非负整数(见width以下)。范围终点(或“结束”)是平等的“开始”加上它的“宽度”减一(见end以下)。一个“空”的范围,是一个范围,不包含任何值,即有一个空的宽度范围。根据上下文,它可以解释要么只是空集的整数,或者更精确的位置之间的“终结”和“开始”(注,一个空的范围,“结束”相当于“开始”减一)。

The length of a Ranges object is the number of ranges in it, not the number of integer values in its ranges.
一个范围对象的长度是在它的范围,而不是在其范围内的整数值。

A Ranges object is considered empty iff all its ranges are empty.
A范围的对象被认为是空的,当且仅当其所有的范围是空的。

Ranges objects have a vector-like semantic i.e. they only support single subscript subsetting (unlike, for example, standard R data frames which can be subsetted by row and by column).
范围对象有像语义,即它们只支持单一的标子集(矢量不同,例如,标准的R数据框可以通过行和列的子集)。

The Ranges class itself is a virtual class. The following classes derive directly from the Ranges class: IRanges and IntervalTree.
范围类本身是一个虚拟类。直接从下面的类派生的范围类:IRanges和IntervalTree。


方法----------Methods----------

In the code snippets below, x, y and object are Ranges objects. Not all the functions described below will necessarily work with all kinds of Ranges objects but they should work at least for IRanges objects. Also more operations on Ranges objects are described in the man page for Ranges-utils (shift, restrict, narrow, reduce, etc...), for IntervalTree objects (findOverlaps), and for RangesList objects (split method for Ranges objects).
在下面的代码片段,x,y和object范围对象。没有下文所述的所有功能将一定范围对象的各种工作,但他们至少应该IRanges对象。 -utils的范围,范围对象上的操作也更说明在手册页(shift,restrict,narrow,reduce等..),IntervalTree对象(findOverlaps),RangesList对象(split范围对象的方法)。

length(x): The number of ranges in x.
length(x):不等x的数量。

start(x): The start values of the ranges. This is an integer vector of the same length as x.
start(x):范围的起始值。这是一个为x相同长度的整数向量。

width(x): The number of integer values in each range. This is a vector of non-negative integers of the same length as x.
width(x):在每个范围的整数值。这是一个非负整数的x长度相同的向量。

end(x): start(x) + width(x) - 1L
end(x):start(x) + width(x) - 1L

mid(x): returns the midpoint of the range, start(x) + floor((width(x) - 1)/2).
mid(x):返回范围的中点,start(x) + floor((width(x) - 1)/2)。

names(x): NULL or a character vector of the same length as x.
names(x):NULL或相同的长度为x特征向量。

update(object, ...): Convenience method for combining multiple modifications of object in one single call. For example object <- update(object, start=start(object)-2L,      end=end(object)+2L) is equivalent to start(object) <- start(object)-2L; end(object) <- end(object)+2L.
update(object, ...):结合多个修改的便捷方法object在一个单一的通话。例如object <- update(object, start=start(object)-2L,      end=end(object)+2L)相当于start(object) <- start(object)-2L; end(object) <- end(object)+2L的。

isEmpty(x): Return a logical value indicating whether x is empty or not.
isEmpty(x):返回一个逻辑值,该值指示是否x为空或不。

isDisjoint(x): Return a logical value indicating whether the ranges x are disjoint (i.e. non-overlapping).
isDisjoint(x):返回一个逻辑值范围是否x是不相交的(即非重叠)。

as.matrix(x, ...): Convert x into a 2-column integer matrix containing start(x) and width(x). Extra arguments (...) are ignored.
as.matrix(x, ...):转换x成2列的整数矩阵包含start(x)和width(x)“。 (...)被忽略额外的参数。

as.data.frame(x, row.names=NULL, optional=FALSE, ...): Convert x into a standard R data frame object. row.names must be NULL or a character vector giving the row names for the data frame, and optional and any additional argument (...) is ignored. See ?as.data.frame for more information about these arguments.
as.data.frame(x, row.names=NULL, optional=FALSE, ...)转换xR的数据到一个标准的框架对象。 row.names必须NULL或特征向量,使数据框的行名,optional“任何额外的参数(...)被忽略。看到?as.data.frame有关这些参数的更多信息。

as.integer(x): Convert x into an integer vector, by converting each range into the integer sequence formed by from:to and concatenating them together.
as.integer(x):转换x成一个整数向量,每个范围转换成整数序列from:to和串联在一起形成的。

unlist(x, recursive = TRUE, use.names = TRUE): Similar to as.integer(x) except can add names to elements.
unlist(x, recursive = TRUE, use.names = TRUE):类似as.integer(x)除了可以添加的元素的名称。

x[[i]]: Return integer vector start(x[i]):end(x[i]) denoted by i. Subscript i can be a single integer or a character string.
x[[i]]:返回整数向量start(x[i]):end(x[i])i表示。标i可以是一个整数或字符串。

x[i]: Return a new Ranges object (of the same type as x) made of the selected ranges. i can be a numeric vector, a logical vector, NULL or missing. If x is a NormalIRanges object and i a positive numeric subscript (i.e. a numeric vector of positive values), then i must be strictly increasing.
x[i]:返回一个新的对象范围(相同类型的x)选定的范围。 i可以是一个数值向量,逻辑向量,NULL或失踪。如果x是一个NormalIRanges对象i积极的数字下标(即一个正面的价值观数字向量),然后i必须严格递增。

rep(x, times, length.out, each): Repeats the values in x through one of the following conventions:
rep(x, times, length.out, each):重复值x通过以下约定:




times Vector giving the number of times to repeat each element if of length length(x), or to repeat the Ranges
times媒介给予的次数,重复每一个元素,如果长度length(x),或重复的范围




length.out Non-negative integer. The desired length of
length.out非负整数。所需的长度




each Non-negative integer.  Each element of x is
each非负整数。每个x元素

c(x, ...): Combine x and the Ranges objects in ... together. Any object in ... must belong to the same class as x, or to one of its subclasses, or must be NULL. The result is an object of the same class as x. NOTE: Only works for IRanges (and derived) objects for now.
c(x, ...):结合x和...一起范围对象。任何对象...“必须属于同一类的x,或者其子类之一,或必须是NULL。其结果是为x同一类的对象。注:的只有IRanges作品(以及派生)现在的对象。

x * y: The arithmetic operation x * y is for centered zooming. It symmetrically scales the width of x by 1/y, where y is a numeric vector that is recycled as necessary. For example, x * 2 results in ranges with half their previous width but with approximately the same midpoint. The ranges have been &ldquo;zoomed in&rdquo;. If y is negative, it is equivalent to x * (1/abs(y)). Thus, x * -2 would double the widths in x. In other words, x has been &ldquo;zoomed out&rdquo;.
x * y:算术运算x * y为中心缩放。它的宽度对称尺度x1/y,其中y是一个数字的向量,是必要的回收。例如,x * 2结果在与他们以前的一半宽的范围内,但大致相同的中点。范围已被“放大”。 y如果是负的,它是相当于到x * (1/abs(y))。因此,x * -2会x翻一番的宽度。换句话说,x一直“放大”。

x + y: Expands the ranges in x on either side by the corresponding value in the numeric vector y.
x + y:在范围扩大x相应的值在数字向量y两侧。


常态----------Normality----------

A Ranges object x is implicitly representing an arbitrary finite set of integers (that are not necessarily consecutive). This set is the set obtained by taking the union of all the values in all the ranges in x. This representation is clearly not unique: many different Ranges objects can be used to represent the same set of integers. However one and only one of them is guaranteed to be "normal".
一个范围对象x隐代表任意一个整数的有限集合(不一定是连续的)。这一套是采取联盟的所有值在所有的x范围得到了一套。这种表述显然是没有独特之处:许多不同的范围对象,可以用来表示同一组的整数。但其中只有一个是保证是“正常”。

By definition a Ranges object is said to be "normal" when its ranges are: (a) not empty (i.e. they have a non-null width); (b) not overlapping; (c) ordered from left to right; (d) not even adjacent (i.e. there must be a non empty gap between 2 consecutive ranges).
根据定义,范围对象,据说是“正常”时,其范围是:(一)不为空(即他们有一个非空的宽度);(b)不重叠;(三)责令从左至右( D)甚至不相邻(即必须是一个非连续2个范围之间的空差距)。

Here is a simple algorithm to determine whether x is "normal": (1) if length(x) == 0, then x is normal; (2) if length(x) == 1, then x is normal iff width(x) >= 1; (3) if length(x) >= 2, then x is normal iff:
下面是一个简单的算法,以确定是否x是“正常”:(1)如果length(x) == 0,x是正常的;(2)如果length(x) == 1,则 x是正常的,当且仅当width(x) >= 1(3)如果length(x) >= 2,则x是正常的,当且仅当:

isNormal(x): Return a logical value indicating whether x is "normal" or not.
isNormal(x):返回一个逻辑值,该值指示是否x是“正常”或不。

whichFirstNotNormal(x): Return NA if x is normal, or the smallest valid indice i in x for which x[1:i] is not "normal".
whichFirstNotNormal(x):返回NA如果x是正常的,或最小的有效证指数ix,x[1:i]是不是“正常” 。


作者(S)----------Author(s)----------


H. Pages and M. Lawrence



参见----------See Also----------

Ranges-comparison, Ranges-utils, IRanges-class, IRanges-utils, IRanges-setops, RangedData-class, IntervalTree-class, update, as.matrix, as.data.frame, rep
范围比较,范围-utils的,IRanges-utils的IRanges级,IRanges setops,RangedData级,级IntervalTree,update,as.matrix,as.data.frame,rep


举例----------Examples----------


  x <- IRanges(start=c(2:-1, 13:15), width=c(0:3, 2:0))
  x
  length(x)
  start(x)
  width(x)
  end(x)
  isEmpty(x)
  as.matrix(x)
  as.data.frame(x)

  ## Subsetting:[#子集:]
  x[4:2]                  # 3 ranges[3档]
  x[-1]                   # 6 ranges[6档]
  x[FALSE]                # 0 range[范围为0]
  x0 &lt;- x[width(x) == 0]  # 2 ranges[2范围]
  isEmpty(x0)

  ## Use the replacement methods to resize the ranges:[#使用替代的方法来调整范围:]
  width(x) <- width(x) * 2 + 1
  x
  end(x) &lt;- start(x)            # equivalent to width(x) &lt;- 0[相当于宽度(X)< -  0]
  x
  width(x) <- c(2, 0, 4)
  x
  start(x)[3] &lt;- end(x)[3] - 2  # resize the 3rd range[调整第三届范围的大小]
  x

  ## Name the elements:[#名称的元素:]
  names(x)
  names(x) <- c("range1", "range2")
  x
  x[is.na(names(x))]  # 5 ranges[5档]
  x[!is.na(names(x))]  # 2 ranges[2范围]

  ## Check for disjointedness[#检查的脱节]
  isDisjoint(IRanges(c(2,5,1), c(3,7,3))) ## FALSE[#假]
  isDisjoint(IRanges(c(2,9,5), c(3,9,6))) ## TRUE[#真]
  isDisjoint(IRanges(1, 5)) ## TRUE[#真]

  ir <- IRanges(c(1,5), c(3,10))
  ir*1 # no change[没有变化]
  ir*c(1,2) # zoom second range by 2X[第二变焦范围由2X]
  ir*-2 # zoom out 2X  [放大了2倍]

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-2-5 13:51 , Processed in 0.023099 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表