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

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

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

                                        Grouping objects
                                         分组对象

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

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

In this man page, we call "grouping" the action of dividing a collection of NO objects into NG groups (some of which may be empty). The Grouping class and subclasses are containers for representing groupings.
在这名男子页面,我们称之为“分组”行动分成吴组(其中一些可能为空)没有对象的集合。分组类和子类是代表集团的容器。


分组核心API----------The Grouping core API----------

Let's give a formal description of the Grouping core API:
让我们给了分组核心API的正式描述:

Groups G_i are indexed from 1 to NG (1 <= i <= NG).
组G_i索引是从1到NG(1 <= I <=吴)。

Objects O_j are indexed from 1 to NO (1 <= j <= NO).
O_j对象索引是从1到NO(1 <= J <= NO)。

Every object must belong to one group and only one.
每个对象必须属于一个组只有一个。

Given that empty groups are allowed, NG can be greater than NO.
鉴于允许空组,NG可以比没有更大。

Grouping an empty collection of objects (NO = 0) is supported. In that case, all the groups are empty. And only in that case, NG can be zero too (meaning there are no groups).
支持分组对象空集合(NO = 0)。在这种情况下,所有的群体都是空的。只有在这种情况下,议员可以是零(意思是有没有组)。

If x is a Grouping object:
如果x是一个分组的对象:

length(x): Returns the number of groups (NG).
length(x):返回的组数(吴)。

names(x): Returns the names of the groups.
names(x):返回组的名称。

nobj(x): Returns the number of objects (NO). Equivalent to length(togroup(x)).
nobj(x):返回的对象的数量(NO)。相当于length(togroup(x))。

Going from groups to objects:
从组的对象:

x[[i]]: Returns the indices of the objects (the j's) that belong to G_i. The j's are returned in ascending order. This provides the mapping from groups to objects (one-to-many mapping).
x[[i]]:返回的对象(j的),属于以G_i指数。 j的升序返回。这提供了从组对象(一到多的映射)的映射。

grouplength(x, i=NULL): Returns the number of objects in G_i. Works in a vectorized fashion (unlike x[[i]]). grouplength(x) is equivalent to grouplength(x, seq_len(length(x))). If i is not NULL, grouplength(x, i) is equivalent to sapply(i, function(ii) length(x[[ii]])).
grouplength(x, i=NULL):返回对象G_i的的数量。在矢量时尚作品(不像x[[i]])。 grouplength(x)相当于grouplength(x, seq_len(length(x)))的。 i如果不为NULL,grouplength(x, i)到sapply(i, function(ii) length(x[[ii]]))相当于。

members(x, i): Equivalent to x[[i]] if i is a single integer. Otherwise, if i is an integer vector of arbitrary length, it's equivalent to sort(unlist(sapply(i, function(ii) x[[ii]]))).
members(x, i):等于x[[i]]如果i是一个整数。否则,如果i是一个任意长度的整数向量,它是相当于sort(unlist(sapply(i, function(ii) x[[ii]])))。

vmembers(x, L): A version of members that works in a vectorized fashion with respect to the L argument (L must be a list of integer vectors). Returns lapply(L, function(i) members(x, i)).
vmembers(x, L):members的版本,在量化的方式L参数(L必须是整数向量的列表)。返回lapply(L, function(i) members(x, i))的。

Going from objects to groups:
从对象的群体:

togroup(x, j=NULL): Returns the index i of the group that O_j belongs to. This provides the mapping from objects to groups (many-to-one mapping). Works in a vectorized fashion. togroup(x) is equivalent to togroup(x, seq_len(nobj(x))): both return the entire mapping in an integer vector of length NO. If j is not NULL, togroup(x, j) is equivalent to y <- togroup(x); y[j].
togroup(x, j=NULL):返回该组的索引i,O_j属于。这提供了从对象映射到组(多到一映射)。作品在矢量时尚。 togroup(x)相当于togroup(x, seq_len(nobj(x))):返回一个整数向量长度不整个映射。 j如果不为NULL,togroup(x, j)到y <- togroup(x); y[j]相当于。

togrouplength(x, j=NULL): Returns the number of objects that belong to the same group as O_j (including O_j itself). Equivalent to grouplength(x, togroup(x, j)).
togrouplength(x, j=NULL):返回的对象属于同一组作为O_j(包括O_j本身)的数量。相当于grouplength(x, togroup(x, j))。

Given that length, names and [[ are defined for Grouping objects, those objects can be considered List objects. In particular, as.list works out-of-the-box on them.
鉴于length,names和[[定义为分组对象,这些对象可以被视为List对象。 ,尤其是as.list出的对他们的盒子。

One important property of any Grouping object x is that unlist(as.list(x)) is always a permutation of  seq_len(nobj(x)). This is a direct consequence of the fact that every object in the grouping belongs to one group and only one.
任何分组对象的一个重要的属性x是unlist(as.list(x))始终是一个seq_len(nobj(x))排列。这是一个事实,即在分组中的每个对象属于一个组只有一个直接后果。


H2LGrouping和DUPS子类----------The H2LGrouping and Dups subclasses----------

[DOCUMENT ME]
[文件我]


分区的子类----------The Partitioning subclass----------

A Partitioning container represents a block-grouping, i.e. a grouping where each group contains objects that are neighbors in the original collection of objects. More formally, a grouping x is a block-grouping iff togroup(x) is sorted in increasing order (not necessarily strictly increasing).
分区容器代表一个块分组,即分组,每组包含的对象,是在原来的对象集合的邻居。更正式的,分组x是块分组IFFtogroup(x)递增顺序(不一定严格递增)排序。

A block-grouping object can also be seen (and manipulated) as a Ranges object where all the ranges are adjacent starting at 1 (i.e. it covers the 1:NO interval with no overlap between the ranges).
块分组对象,也可以看到和操纵范围为1(即它包括1:没有,没有重叠的范围之间的间隔)开始,所有的范围是相邻的对象。

Note that a Partitioning object is both: a particular type of Grouping object and a particular type of Ranges object. Therefore all the methods that are defined for Grouping and Ranges objects can also be used on a Partitioning object. See ?Ranges for a description of the Ranges API.
需要注意的是分区的对象是两个:一个特定类型的对象和范围对象的特定类型分组。因此,所有的分组和范围对象中定义的方法也可用于对分区对象。看到?Ranges的范围API的描述。

The Partitioning class is virtual with 2 concrete subclasses: PartitioningByEnd (only stores the end of the groups, allowing fast mapping from groups to objects), and PartitioningByWidth (only stores the width of the groups).
分区类是与虚拟2个具体的子类:PartitioningByEnd(只存储组结束时,允许从对象组的快速映射),PartitioningByWidth(只存储组的宽度)。


分级的子类----------Binning subclass----------

WARNING: The Binning subclass is deprecated!
警告:分级子类已过时!

A Binning container represents a grouping where each observation is assigned to a group or bin. It is similar in nature to taking a the integer codes of a factor object and splitting it up by its levels (i.e. myFactor <- factor(...); split(as.integer(myFactor), myFactor)).
一个分级的容器表示,其中每个观察被分配到一组或bin的分组。它在本质上是类似考虑的一个因素对象和分裂,其水平的整数代码(即myFactor < - 因子(...);分裂(as.integer(myFactor),myFactor))。


构造----------Constructors----------

H2LGrouping(high2low=integer()): [DOCUMENT ME]
H2LGrouping(high2low=integer()):[文档ME的]

Dups(high2low=integer()): [DOCUMENT ME]
Dups(high2low=integer()):[文档ME的]

PartitioningByEnd(end=integer(), names=NULL): Return the PartitioningByEnd object made of the partitions ending at the values specified by end. end must contain sorted non-negative integer values. If the names argument is non NULL, it is used to name the partitions.
PartitioningByEnd(end=integer(), names=NULL):返回PartitioningByEnd的对象的在end指定的值结束的分区。 end必须包含非负整数的值排序。如果names参数非空,它是用来命名的分区。

PartitioningByWidth(width=integer(), names=NULL): Return the PartitioningByWidth object made of the partitions with the widths specified by width. width must contain non-negative integer values. If the names argument is non NULL, it is used to name the partitions.
PartitioningByWidth(width=integer(), names=NULL):返回PartitioningByWidth的对象的与width指定的宽度,分区。 width必须包含非负整数的值。如果names参数非空,它是用来命名的分区。

WARNING: Binning objects are deprecated!
警告:分级对象已被弃用!

Binning(group=integer(), names=NULL): Return the Binning object made from the group argument, which takes a factor or positive valued integer vector. If the names argument is non NULL, it is used to name the bins. When group is a factor, the names are set to levels(group) unless specified otherwise.
Binning(group=integer(), names=NULL):返回分级对象group的说法,这需要一个因素或积极价值整数向量制成。如果names参数非空,它是用来命名的垃圾箱。当group是一个因素,names设置为levels(group)除非另有规定。

Note that these constructors don't recycle their names argument (to remain consistent with what `names<-` does on standard vectors).
请注意,这些构造不回收他们的names参数(什么names<-标准的向量保持一致)。


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


H. Pages and P. Aboyoun



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

List-class, Ranges-class, IRanges-class, successiveIRanges, cumsum, diff
列表类,范围类,级IRanges,successiveIRanges,cumsum,差异


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


  showClass("Grouping")  # shows (some of) the known subclasses[表演(部分)已知的子类]

  ## ---------------------------------------------------------------------[#------------------------------------------------- --------------------]
  ## A. H2LGrouping OBJECTS[#答H2LGrouping对象]
  ## ---------------------------------------------------------------------[#------------------------------------------------- --------------------]
  high2low <- c(NA, NA, 2, 2, NA, NA, NA, 6, NA, 1, 2, NA, 6, NA, NA, 2)
  x <- H2LGrouping(high2low)
  x

  ## The Grouping core API:[#分组核心API:]
  length(x)
  nobj(x)  # same as 'length(x)' for H2LGrouping objects[相同的长度(X)“H2LGrouping对象]
  x[[1]]
  x[[2]]
  x[[3]]
  x[[4]]
  x[[5]]
  grouplength(x)  # same as 'unname(sapply(x, length))'[同为“unname(sapply(X,长度))”]
  grouplength(x, 5:2)
  members(x, 5:2)  # all the members are put together and sorted[所有成员都放在一起和排序]
  togroup(x)
  togroup(x, 5:2)
  togrouplength(x)  # same as 'grouplength(x, togroup(x))'[相同的“grouplength(X,togroup(X))”]
  togrouplength(x, 5:2)

  ## The List API:[#名单API:]
  as.list(x)
  sapply(x, length)

  ## ---------------------------------------------------------------------[#------------------------------------------------- --------------------]
  ## B. Dups OBJECTS[#乙DUPS对象]
  ## ---------------------------------------------------------------------[#------------------------------------------------- --------------------]
  x_dups <- as(x, "Dups")
  x_dups
  duplicated(x_dups)  # same as 'duplicated(togroup(x_dups))'[一样“重复(togroup(x_dups))”]

  ### The purpose of a Dups object is to describe the groups of duplicated[#一个DUPS对象的目的是描述重复组]
  ### elements in a vector-like object:[#要素矢量对象:]
  x <- c(2, 77, 4, 4, 7, 2, 8, 8, 4, 99)
  x_high2low <- high2low(x)
  x_high2low  # same length as 'x'[相同的长度为“X”]
  x_dups <- Dups(x_high2low)
  x_dups
  togroup(x_dups)
  duplicated(x_dups)
  togrouplength(x_dups)  # frequency for each element[每个元素的频率]
  table(x)

  ## ---------------------------------------------------------------------[#------------------------------------------------- --------------------]
  ## C. Partitioning OBJECTS[#三分区的物体]
  ## ---------------------------------------------------------------------[#------------------------------------------------- --------------------]
  x <- PartitioningByEnd(end=c(4, 7, 7, 8, 15), names=LETTERS[1:5])
  x  # the 3rd partition is empty[第三分区是空的]

  ## The Grouping core API:[#分组核心API:]
  length(x)
  nobj(x)
  x[[1]]
  x[[2]]
  x[[3]]
  grouplength(x)  # same as 'unname(sapply(x, length))' and 'width(x)'[同样作为“unname(sapply(X,长度))”和“宽度(X)”]
  togroup(x)
  togrouplength(x)  # same as 'grouplength(x, togroup(x))'[相同的“grouplength(X,togroup(X))”]
  names(x)

  ## The Ranges core API:[#范围的核心API:]
  start(x)
  end(x)
  width(x)

  ## The List API:[#名单API:]
  as.list(x)
  sapply(x, length)

  ## Replacing the names:[#更换名称:]
  names(x)[3] <- "empty partition"
  x

  ## Coercion to an IRanges object:[#强制到IRanges对象:]
  as(x, "IRanges")

  ## Other examples:[#其他的例子:]
  PartitioningByEnd(end=c(0, 0, 19), names=LETTERS[1:3])
  PartitioningByEnd()  # no partition[不分区]
  PartitioningByEnd(end=integer(9))  # all partitions are empty[所有的分区都是空的]

  ## ---------------------------------------------------------------------[#------------------------------------------------- --------------------]
  ## D. RELATIONSHIP BETWEEN Partitioning OBJECTS AND successiveIRanges()[#四分区对象和successiveIRanges关系()]
  ## ---------------------------------------------------------------------[#------------------------------------------------- --------------------]
  mywidths <- c(4, 3, 0, 1, 7)

  ## The 3 following calls produce the same ranges:[#3以下调用产生相同的范围:]
  x1 &lt;- successiveIRanges(mywidths)  # IRanges instance.[IRanges实例。]
  x2 &lt;- PartitioningByEnd(end=cumsum(mywidths))  # PartitioningByEnd instance.[PartitioningByEnd实例。]
  x3 &lt;- PartitioningByWidth(width=mywidths)  # PartitioningByWidth instance.[PartitioningByWidth实例。]
  stopifnot(identical(as(x1, "PartitioningByEnd"), x2))
  stopifnot(identical(as(x1, "PartitioningByWidth"), x3))

  ## ---------------------------------------------------------------------[#------------------------------------------------- --------------------]
  ## E. Binning OBJECTS[#E。分级对象]
  ## ---------------------------------------------------------------------[#------------------------------------------------- --------------------]
  ## WARNING: Binning objects are deprecated![#警告:分级对象已被弃用!]
  set.seed(0)
  x <- Binning(factor(sample(letters, 36, replace=TRUE), levels=letters))
  x

  grouplength(x)
  togroup(x)
  x[[2]]
  x[["u"]]

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-2-5 16:50 , Processed in 0.029428 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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