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

R语言 WGCNA包 cor()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-10-1 21:11:04 | 显示全部楼层 |阅读模式
cor(WGCNA)
cor()所属R语言包:WGCNA

                                         Fast calculations of Pearson correlation.
                                         Pearson相关系数的快速计算。

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

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

These functions implements a faster calculation of Pearson correlation.
这些功能实现了更快的计算Pearson相关。

The speedup against the R's standard cor function will be substantial particularly if the input matrix only contains a small number of missing data. If there are no missing data, or the missing data are numerous, the speedup will be smaller but still present.  
加速对R的标准cor函数将是巨大的,特别是如果输入矩阵只含有少量的丢失的数据。如果没有数据丢失,或者丢失的数据是多不胜数,增速会小一些,但仍然存在。


用法----------Usage----------


cor(x, y = NULL,
    use = "all.obs",
    method = c("pearson", "kendall", "spearman"),
    quick = 0,
    cosine = FALSE,
    cosineX = cosine,
    cosineY = cosine,
    nThreads = 0,
    verbose = 0, indent = 0)

corFast(x, y = NULL,
    use = "all.obs",
    quick = 0, nThreads = 0,
    verbose = 0, indent = 0)

cor1(x, use = "all.obs", verbose = 0, indent = 0)




参数----------Arguments----------

参数:x
a numeric vector or a matrix. If y is null, x must be a matrix.  
一个数值向量或矩阵。如果y是空,x必须是一个矩阵。


参数:y
a numeric vector or a matrix. If not given, correlations of columns of x will be calculated.  
一个数值向量或矩阵。如果没有给定,相关的列x将被计算。


参数:use
a character string specifying the handling of missing data. The fast calculations currently support "all.obs" and "pairwise.complete.obs"; for other options, see R's standard correlation function cor.  Abbreviations are allowed.  
一个字符串指定丢失的数据处理。快速的计算,目前支持"all.obs"和"pairwise.complete.obs";其他选项,请参阅R的标准相关功能cor。缩写是允许的。


参数:method
a character string specifying the method to be used. Fast calculations are currently available only for "pearson".  
一个字符的字符串,指定要使用的方法。快速的计算,目前仅适用于"pearson"。


参数:quick
real number between 0 and 1 that controls the precision of handling of missing data in the calculation of correlations. See details.  
实数0和1之间,控制处理丢失的数据的相关性的计算中的精度。查看详细信息。


参数:cosine
logical: calculate cosine correlation? Only valid for method="pearson". Cosine correlation is similar to Pearson correlation but the mean subtraction is not performed. The result is the cosine of the angle(s) between (the columns of) x and y.  
逻辑:计算余弦关系吗?只适用为method="pearson"。余弦相关Pearson相关系数是类似的,但不进行平均减法。其结果是该角度的余弦值()之间(列)x和y。


参数:cosineX
logical: use the cosine calculation for x? This setting does not affect y and can be used to give a hybrid cosine-standard correlation.  
符合逻辑的:使用的余弦计算x的吗?此设置不会影响y和可以用来给一个混合的余弦标准的相关。


参数:cosineY
logical: use the cosine calculation for y? This setting does not affect x and can be used to give a hybrid cosine-standard correlation.  
符合逻辑的:使用的余弦计算y的吗?此设置不会影响x和可以用来给一个混合的余弦标准的相关。


参数:nThreads
non-negative integer specifying the number of parallel threads to be used by certain parts of correlation calculations. This option only has an effect on systems on which a POSIX thread library is available (which currently includes Linux and Mac OSX, but excludes Windows). If zero, the number of online processors will be used if it can be determined dynamically, otherwise correlation calculations will use 2 threads.  
非负的整数,用于指定要使用的某些部分的相关性计算的并行线程的数目。此选项仅影响的系统上POSIX线程库(目前包括Linux和Mac OSX,但不包括视窗)。如果为零,则在线的处理器的数目将被使用,如果是可以动态地确定,否则将使用相关计算2个线程。


参数:verbose
Controls the level of verbosity. Values above zero will cause a small amount of diagnostic messages to be printed.  
控制的详细程度。大于零的值会导致要打印少量的诊断消息。


参数:indent
Indentation of printed diagnostic messages. Each unit above zero adds two spaces.
压痕印刷的诊断消息。在零以上每个单元增加了两个空格。


Details

详细信息----------Details----------

The fast calculations are currently implemented only for method="pearson" and use either "all.obs" or "pairwise.complete.obs".  The corFast function is a wrapper that calls the function cor. If the combination of method and use is implemented by the fast calculations, the fast code is executed;  otherwise, R's own correlation cor is executed.
目前只实现快速的计算method="pearson"和use是"all.obs"或"pairwise.complete.obs"。 corFast功能是一个包装调用该函数cor。如果结合method use是通过快速的计算,快速的代码执行,否则,R的相关cor执行。

The argument quick specifies the precision of handling of missing data. Zero will cause all calculations to be executed precisely, which may be significantly slower than calculations without missing data. Progressively higher values will speed up the calculations but introduce progressively larger errors. Without missing data, all column means and variances can be pre-calculated before the covariances are calculated. When missing data are present, exact calculations require the column means and variances to be calculated for each covariance. The approximate calculation uses the pre-calculated mean and variance and simply ignores missing data in the covariance calculation. If the number of missing data is high, the pre-calculated means and variances may be very different from the actual ones, thus potentially introducing large errors.  The quick value times the number of rows specifies the maximum difference in the  number of missing entries for mean and variance calculations on the one hand and covariance on the other    hand that will be tolerated before a recalculation is triggered. The hope is that if only a few missing data are treated approximately, the error introduced will be small but the potential speedup can be significant.
参数quick指定丢失的数据处理的精度。为零,将导致所有的计算精确被执行,这可能是明显慢于没有丢失的数据的计算。值会逐步提高计算的速度,但介绍逐步误差较大。没有丢失的数据,所有的列均值和方差,可以预先计算出的协方差计算之前。当丢失的数据,精确的计算需要为每个协方差列的均值和方差来计算。的近似计算使用预先计算的均值和方差,并简单地忽略丢失数据的协方差计算。如果丢失的数据的数目是高的,预先计算的均值和方差可能从实际的是非常不同的,从而有可能引入较大的误差。 quick值乘以的行数指定缺少的条目,用于一方面和协方差,在另一方面,将重新计算被触发之前被容忍的均值和方差计算的数目的最大差值。希望是,如果只有很少的缺失数据处理约,将引入的误差小,但潜在的加速可能是显着的。


值----------Value----------

The matrix of the Pearson correlations of the columns of x with columns of y if y is given, and the correlations of the columns of x if y is not given.
的Pearson相关性的列的矩阵x列y如果y,并给出相关的x如果y的列没有给出。


注意----------Note----------

The implementation uses the BLAS library matrix multiplication function for the most expensive step of the calculation. Using a tuned, architecture-specific BLAS may significantly improve the performance of this function.
在实现中使用的BLAS库的矩阵乘法函数的计算最昂贵的步骤。使用调谐,特定于体系结构的BLAS,此功能可以显着提高性能。

The values returned by the corFast function may differ from the values returned by R's function cor by rounding errors on the order of 1e-15.
从返回的值R的功能cor舍入误差1E-15的顺序的corFast函数返回的值可能会有所不同。


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


Peter Langfelder



参考文献----------References----------

Fast R Functions for Robust Correlations and Hierarchical Clustering. Journal of Statistical Software, 46(11), 1-17. http://www.jstatsoft.org/v46/i11/

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

R's standard Pearson correlation function cor.
R的标准Pearson相关函数cor。


实例----------Examples----------



## Test the speedup compared to standard function cor[#测试标准功能对应的增速相比,]

# Generate a random matrix with 200 rows and 1000 columns[200行和1000列生成一个随机矩阵]

set.seed(10)
nrow = 100;
ncol = 500;
data = matrix(rnorm(nrow*ncol), nrow, ncol);

## First test: no missing data[#第一个测试:没有丢失的数据]

system.time( {corStd = stats::cor(data)} );

system.time( {corFast = cor(data)} );

all.equal(corStd, corFast)

# Here R's standard correlation performs very well.[R的标准相关性表现得非常好。]

# We now add a few missing entries.[现在,我们添加一些遗漏的项目。]

data[sample(nrow, 10), 1] = NA;

# And test the correlations again...[并再次测试的相关性...]

system.time( {corStd = stats::cor(data, use ='p')} );

system.time( {corFast = cor(data, use = 'p')} );

all.equal(corStd, corFast)

# Here the R's standard correlation slows down considerably, while corFast still retains it speed. Choosing[这里的R标准的相关性会显着降低,而corFast仍然保留了它的速度。选择]
# higher ncol above will make the difference more pronounced.[高NCOL以上的差异更加明显。]


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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-25 06:27 , Processed in 0.020371 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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