将dada2安装到通过condas安装的R版本中(installing dada2 into a version of R that was installed through condas)
我有一个通过condas安装R的环境(我目前使用R与jupyter笔记本,所以这是有道理的一点)。 我想在这个版本的R中使用dada2。
根据这个网站https://anaconda.org/bioconda/bioconductor-dada2正确的命令来实现这一点是
conda install -c bioconda bioconductor-dada2
这给我以下错误
获取包元数据.............解决包的规格:。
不可分析的错误:发现以下规范存在冲突: - 生物导体 - 数据2 - >生物导体 - 生物导体> = 2.32.1 - >生物导体 - 生物共同体> = 0.15.6 - > r 3.3.1 * - > r碱基3.3。 1 - r-glue使用“conda info”查看每个软件包的依赖关系。
如果我运行
conda info package r-glue
我可以看到它取决于r-base 3.4.1。另一种方法也行不通:
我也尝试进入R并从那里安装,但我无法获得任何软件包来安装R软件包
source("https://bioconductor.org/biocLite.R") biocLite("dada2")
给我一个非常长的输出,但缺点是一堆依赖返回错误
错误:编译包'RcppParallel'失败*删除'/ home / jacob / anaconda3 / lib / R / library / RcppParallel'错误:依赖'S4Vectors'不可用于包'IRanges'*删除'/ home / jacob / anaconda3 / lib / R / library / IRanges'错误:依赖关系'S4Vectors','IRanges','matrixStats'不可用于包'DelayedArray'
然后更多的东西,并在最后
错误:依赖'Biostrings','ShortRead','RcppParallel'不可用于包'dada2'*删除'/ home / jacob / anaconda3 / lib / R / library / dada2'
下载的源码包在'/ tmp / Rtmptx8OqE / downloaded_packages'中更新'.Library'中包的HTML索引制作'packages.html'...完成旧包:'curl','dplyr','foreign',' haven','httpuv','mgcv','purrr','Rcpp','TTR','xts'更新全部/部分/无? [A / S / N]:
然后所有的更新都失败了。
是否正确的答案是不尝试在R中使用dada2和condas,而只是使用condas独立版本的R,还是有一些我缺少的方法?
我在ubuntu linux 16.04和conda 3.2.23上运行R版本3.4.1,以获得更多价值。
I have an environment with R installed through condas (I currently use R with jupyter notebook, so this made sense at one point). I would like to use dada2 with this version of R.
As per this site https://anaconda.org/bioconda/bioconductor-dada2 the correct command to make this happen is
conda install -c bioconda bioconductor-dada2
which gives me the following error
Fetching package metadata ............. Solving package specifications: .
UnsatisfiableError: The following specifications were found to be in conflict: - bioconductor-dada2 -> bioconductor-biostrings >=2.32.1 -> bioconductor-biocgenerics >=0.15.6 -> r 3.3.1* -> r-base 3.3.1 - r-glue Use "conda info " to see the dependencies for each package.
If I run
conda info package r-glue
I can see that it depends on r-base 3.4.1.Alternative approach that also doesn't work:
I also tried going into R and installing from there, but I can't get any packages to install with R packages
source("https://bioconductor.org/biocLite.R") biocLite("dada2")
Gives me a really long output, but the short of it is that a bunch of the dependencies return errors
ERROR: compilation failed for package ‘RcppParallel’ * removing ‘/home/jacob/anaconda3/lib/R/library/RcppParallel’ ERROR: dependency ‘S4Vectors’ is not available for package ‘IRanges’ * removing ‘/home/jacob/anaconda3/lib/R/library/IRanges’ ERROR: dependencies ‘S4Vectors’, ‘IRanges’, ‘matrixStats’ are not available for package ‘DelayedArray’
and then more stuff and at the end
ERROR: dependencies ‘Biostrings’, ‘ShortRead’, ‘RcppParallel’ are not available for package ‘dada2’ * removing ‘/home/jacob/anaconda3/lib/R/library/dada2’
The downloaded source packages are in ‘/tmp/Rtmptx8OqE/downloaded_packages’ Updating HTML index of packages in '.Library' Making 'packages.html' ... done Old packages: 'curl', 'dplyr', 'foreign', 'haven', 'httpuv', 'mgcv', 'purrr', 'Rcpp', 'TTR', 'xts' Update all/some/none? [a/s/n]:
and then all of the updates fail too.
Is the correct answer to not try to use dada2 with condas in R and rather just use a condas independent version of R, or is there some way that I am missing?
I am running R version 3.4.1 on ubuntu linux 16.04 and conda 3.2.23 for what that is worth.
原文:https://stackoverflow.com/questions/45556517
最满意答案
我想你可能使用
decimal
模块中的Decimal()
对象? (如果你需要两位数字的精度超过小数点,任意大的数字,你绝对应该是,这就是你的问题的标题建议...)如果是这样,文档的十进制常规部分有一个可能对您有用的问题/答案对:
Q.在具有两个小数位的定点应用程序中,一些输入有很多地方需要舍入。 其他人不应该有多余的数字,需要验证。 应该使用什么方法?
A. quantize()方法舍入到固定的小数位数。 如果设置了Inexact陷阱,它也可用于验证:
>>> TWOPLACES = Decimal(10) ** -2 # same as Decimal('0.01') >>> # Round to two places >>> Decimal('3.214').quantize(TWOPLACES) Decimal('3.21') >>> # Validate that a number does not exceed two places >>> Decimal('3.21').quantize(TWOPLACES, context=Context(traps=[Inexact])) Decimal('3.21') >>> Decimal('3.214').quantize(TWOPLACES, context=Context(traps=[Inexact])) Traceback (most recent call last): ... Inexact: None
下一个问题读
问:一旦我有两个地方有效的输入,那么如何在整个应用程序中保持不变呢?
如果您需要答案(以及许多其他有用的信息),请参阅文档的上述部分 。 另外,如果你的
Decimal
保持在Decimal
的两位数字,这意味着要保持小数点左边的所有数字和它的右边的两位数,而不是更多的精确度) ,然后将它们转换成带有str
可以正常工作:str(Decimal('10')) # -> '10' str(Decimal('10.00')) # -> '10.00' str(Decimal('10.000')) # -> '10.000'
I suppose you're probably using the
Decimal()
objects from thedecimal
module? (If you need exactly two digits of precision beyond the decimal point with arbitrarily large numbers, you definitely should be, and that's what your question's title suggests...)If so, the Decimal FAQ section of the docs has a question/answer pair which may be useful for you:
Q. In a fixed-point application with two decimal places, some inputs have many places and need to be rounded. Others are not supposed to have excess digits and need to be validated. What methods should be used?
A. The quantize() method rounds to a fixed number of decimal places. If the Inexact trap is set, it is also useful for validation:
>>> TWOPLACES = Decimal(10) ** -2 # same as Decimal('0.01') >>> # Round to two places >>> Decimal('3.214').quantize(TWOPLACES) Decimal('3.21') >>> # Validate that a number does not exceed two places >>> Decimal('3.21').quantize(TWOPLACES, context=Context(traps=[Inexact])) Decimal('3.21') >>> Decimal('3.214').quantize(TWOPLACES, context=Context(traps=[Inexact])) Traceback (most recent call last): ... Inexact: None
The next question reads
Q. Once I have valid two place inputs, how do I maintain that invariant throughout an application?
If you need the answer to that (along with lots of other useful information), see the aforementioned section of the docs. Also, if you keep your
Decimal
s with two digits of precision beyond the decimal point (meaning as much precision as is necessary to keep all digits to the left of the decimal point and two to the right of it and no more...), then converting them to strings withstr
will work fine:str(Decimal('10')) # -> '10' str(Decimal('10.00')) # -> '10.00' str(Decimal('10.000')) # -> '10.000'
相关问答
更多-
这可以工作: floor($number * 100) / 100 This can work: floor($number * 100) / 100
-
我想你可能使用decimal模块中的Decimal()对象? (如果你需要两位数字的精度超过小数点,任意大的数字,你绝对应该是,这就是你的问题的标题建议...) 如果是这样,文档的十进制常规部分有一个可能对您有用的问题/答案对: Q.在具有两个小数位的定点应用程序中,一些输入有很多地方需要舍入。 其他人不应该有多余的数字,需要验证。 应该使用什么方法? A. quantize()方法舍入到固定的小数位数。 如果设置了Inexact陷阱,它也可用于验证: >>> TWOPLACES = Decimal(10) ...
-
您可以使用String.format("%.2f", d) ,双击将自动舍入。 You can use String.format("%.2f", d), your double will be rounded automatically.
-
格式化数字为2位小数(Format number to 2 decimal places)[2022-05-09]
你想使用TRUNCATE命令。 http://dev.mysql.com/doc/refman/5.0/en/mathematical-functions.html#function_truncate You want to use the TRUNCATE command. https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_truncate -
...最好不解析和操纵.toFixed(2)出来的字符串? 好吧,你可以用数字来做,尽管我担心在数字逻辑和固定的逻辑之间取得完美的匹配,因为toFixed的定义包括以下短语: 设n是n ÷10 f - x的精确数学值尽可能接近零的整数。 如果有两个这样的n ,选择较大的n 。 所以我可能只是更新字符串,这不是很多工作: function formatNumber(num) { return num.toFixed(2).replace(/\.00$/, ""); } function te ...
-
如果你只想剥离零点: >>> '12.000'.rstrip('0') '12.' If you only want to strip zeroes: >>> '12.000'.rstrip('0') '12.'
-
不使用科学记数法将小数点格式化为小数位数(Format decimal to number of decimal places without scientific notation)[2022-08-20]
你可以尝试这样: 0.1234567.ToString("0.####") 还要检查自定义数字格式字符串 # 用相应的数字代替“#”符号(如果有的话); 否则,结果字符串中不会出现数字。 也正如Jon所指出的,它会围绕你的号码。 见注释部分 舍入和固定点格式字符串 对于定点格式字符串(即,不包含科学记数法格式字符的格式字符串),数字将舍入到小数点右侧的数字占位符的小数位数。 You can try like this: 0.1234567.ToString("0.####") Also check Cu ... -
.NET字符串格式化 - 小数点左边的#是什么意思?(.NET String formatting -What does the # mean to the left of the decimal point?)[2023-08-14]
为了解释您引用的文档 , #使该位置的数字可选。 如果该号码在该位置有一个重要数字,它将被打印; 否则它不会。 看看这个例子: String.Format("{0:0.##}, {0:#.##}", 0.5) 这将输出 0.5, .5 或许是一个更明确的例子: String.Format("{0:000.000}, {0:###.###}", 0.5) 这将输出 000.500, .5 To paraphrase the documentation that you cited, the # mak ... -
检查小数是否包含小数元素,并根据结果返回不同的表示: public string GetFormatStringForDecimal(myDec){ return (Decimal.Ceiling(myDec) > myDec) ? "C2" : "C0"; } 此函数将返回问题中指定的小数的格式字符串。 Check whether the decimal contains a fractional element and return a different representation dep ...
-
格式小数,正负和零值到2位小数格式(Format decimal with positive negative and zero value to 2 decimal places format)[2022-02-03]
尝试NumberStyles.Number ,这将工作: decimal price = -3; decimal result = decimal.Parse(price.ToString("##.00"), NumberStyles.Number); //Result: -3,00 (comma because I live in Europe :D) 希望这可以帮助! 编辑: 要确保逗号使用德语CultureInfo,因为它们使用逗号表示小数,将句点用作千位分隔符: decimal price = - ...