daily R_LANG Commands

R is a free software environment for statistical computing and graphics. It compiles and runs on a wide variety of UNIX platforms, Windows and MacOS.

1. related to environment variables
Sys.getenv()
Sys.setenv(BINPREF = “”)

## try http:// if https:// URLs are not supported

2. Change directory: setwd(‘E:/’) or setwd(“E:/”)
caveat: use ‘/’ not ‘\’ in windows.
*: list items in the current directory: dir()

3. bioconductor:
options(BioC_mirror=”https://mirrors.ustc.edu.cn/bioc/”) #换成国内的源,用于加速
if (!requireNamespace(“BiocManager”, quietly = TRUE))
install.packages(“BiocManager”)
BiocManager::install(“ChIPseeker”)

4. update, remove packages
update.packages()
remove.packages()

5. upgrade R
library(installr)
updateR()

6. rstudio换源加速

7. BiocManager换源
源列表:https://www.bioconductor.org/about/mirrors/
options(BioC_mirror=”http://mirrors.ustc.edu.cn/bioc/”)

 

The support of gamma function in Perl

I want a gamma function and try to install Math::GammaFunction package in Perl but fail finally.
The last update of this package is 2007.1.
I can guess the grammar of this package is far from the current standard.
Finally I decide to use Python.

spearman’s rank correlation coefficient 斯皮尔曼等级相关系数

该系数(斯皮尔曼等级相关系数)是一种技术,能够被用于总结两个变量之间关系的强度和方向(负相关或正相关)。计算出来的数值在-1到1之间。

1. 计算该系数的方法:

  • Create a table from your data.
Convenience Store Distance from CAM (m) Rank distance Price of 50cl bottle (€) Rank price Difference between ranks (d) d2
1 50 10 1.8 2 8 64
2 175 9 1.2 3.5 5.5 30.25
3 270 8 2 1 7 49
4 375 7 1 6 1 1
5 425 6 1 6 0 0
6 580 5 1.2 3.5 1.5 2.25
7 710 4 0.8 9 -5 25
8 790 3 0.6 10 -7 49
9 890 2 1 6 -4 16
10 980 1 0.85 8 -7 49
∑d2 = 285.5
  • Rank the two data sets. Ranking is achieved by giving the ranking ‘1’ to the biggest number in a column, ‘2’ to the second biggest value and so on. The smallest value in the column will get the lowest ranking. This should be done for both sets of measurements.
  • Tied scores are given the mean (average) rank. For example, the three tied scores of 1 euro in the example below are ranked fifth in order of price, but occupy three positions (fifth, sixth and seventh) in a ranking hierarchy of ten. The mean rank in this case is calculated as (5+6+7)/3 = 6.
  • Find the difference in the ranks (d): This is the difference between the ranks of the two values on each row of the table. The rank of the second value (price) is subtracted from the rank of the first (distance from the museum).
  • Square the differences (d2) To remove negative values and then sum them (d2).
  • Calculate the coefficient (Rs) using the formula below. The answer will always be between 1.0 (a perfect positive correlation) and -1.0 (a perfect negative correlation).

Now to put all these values into the formula.

  • Find the value of all the d2 values by adding up all the values in the Difference column. In our example this is 285.5. Multiplying this by 6 gives 1713.
  • Now for the bottom line of the equation. The value n is the number of sites at which you took measurements. This, in our example is 10. Substituting these values into n3 – n we get 1000 – 10
  • We now have the formula: Rs = 1 – (1713/990) which gives a value for Rs:

1 – 1.73 = -0.73

2. 检验该关联的显著性

这里网页上直接提供了,计算好的各个显著性的r值,让我们用自己算出来的r值与之对比。没有提供计算方法。

维基百科(https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient#Determining_significance)提供了三种算法。

更多信息参考网页:https://geographyfieldwork.com/SpearmansRank.htm (谷歌搜索推荐位为1)

 

 

 

win10 hyper-v 关闭

修改项一:

1. 打开,控制面板
win+r, control
2. 打开,卸载程序
3. 启用或关闭Windows功能
4. 点掉Hyper-V, container (反之,启用docker就点回来)

修改项二:

1. win+r, bcdedit
2. bcdedit /set hypervisorlaunchtype off

further reading:

https://superuser.com/questions/1391838/virtual-box-is-not-working-on-windows-10
https://blog.csdn.net/imilano/article/details/83038682

 

Acrobat Pro DC shortcut keys

acrobat 不支持修改快捷键,只能使用默认的快捷键。

1. 缩放:ctrl+2, 适合宽度;ctrl+1, 实际大小
2. 隐藏:F8 隐藏工具栏,F9隐藏菜单栏
3. 添加文本注释:
4. 首选项:ctrl+k
5. 手型工具:h
6. 选择文本工具:v
7. 高亮文本工具:u

Elysia chlorotica

1. A draft genome assembly of the solar-powered sea slug Elysia chlorotica. 2019.2.19 scientific data

2. Genome Analysis of Elysia chlorotica Egg DNA Provides No Evidence for Horizontal Gene Transfer into the Germ Line of This Kleptoplastic Mollusc. 2013.8 molecular biology and evolution

 

欧几里得算法及其扩展形式

#详见算法导论

windows 网络配置

windows的网络在使用了很长一段时间,各种VPN,网络代理工具处理后,可能变得情况很复杂,然后就容易联网中断。

现在开始系统梳理一下这个网络问题。

1. netsh winsock reset:【原理待续】

2. 网络连接:重置网络:【原理待续】

 

daily & sophisticated shell built-in commands

1. compgen -b:display all built-in commands (completion of command)

2. type command: determine whether the command is a built-in command

3. pushd/popd: add/remove directories from stack

4. help command: display the help message of the command

R_LANG on MS Windows

1. Suits: R, RTools & Rstudio

2. environment variables:
Modify the variable  BINPREF in the file “/R-3.6.0/etc/x64/Makeconf” to “/path/to/Rtools/mingw_64/bin/” to solve a compiling error.

3. configure R environment:~/.Rprofile, R/R-x.x.x/etc/Rprofile.site

useful git command

1. windows下git对路径名长度存在限制,即使win10系统本身解除了这个限制。

git config –global core.longpaths true

但是没用,仍然报错:fatal: ‘$GIT_DIR’ too big

2.

安装glibc (libc.so.6 GLIBC_)

1. 安装glibc-2.29 (系统:Linux version 2.6.32)

GNU libc requires kernel header files from Linux 3.2.0 or later to be installed before configuring. checking installed Linux kernel header files… missing or too old!

添加&修改windows字体

1.添加字体

将ttf或者otf文件直接复制粘贴到文件夹:C:\Windows\Fonts,系统就会自动安装该字体。然后打开word或者adobe acrobat pro等软件就可以看到新的字体了。

2. 修改字体的名称

  • 使用font creator软件打开字体,然后点击“Font->Properties”;
  • 软件里面显示的字体名称:在identification标签页里面修改“font family”“Full font name”;
  • Font文件夹处的显示:在extended标签页里面修改“typographical family”“typographic subfamily”;

ulimit

1.参数:

-u: 最大进程数

-n: 最大文件句柄数目

2.soft limit vs hard limit

ulimit -S -a view all soft limits

ulimit -H -a view all hard limits

3.

 

 

gcc options

1.-Werror

视警告为错误;出现任何警告即放弃编译.

2.-Wl,-rpath

向ld传递-rpath参数,add a direcory to the runtime library search path. This is used when linking an ELF executable with shared objects. All -rpath arguments are concatenated and passed to the runtime linker, which uses them to locate shared objects at runtime.

3.环境变量

LD_LIBRARY_PATH=”/path/to/lib”, LDFLAGS=”-L/path/to/lib”, C_INCLUDE_PATH=”-I/path/to/include”, CFLAGS, CPPFLAGS

python 单元测试

unittest

https://docs.python.org/2/library/unittest.html

A testcase is created by subclassing unittest.TestCase. The three individual tests are defined with methods whose names start with the letters test. This naming convention informs the test runner about which methods represent tests.

The crux of each test is a call to assertEqual() to check for an expected result; assertTrue() or assertFalse() to verify a condition; or assertRaises() to verify that a specific exception gets raised. These methods are used instead of the assert statement so the test runner can accumulate all test results and produce a report.

The setUp() and tearDown() methods allow you to define instructions that will be executed before and after each test method. They are covered in more detail in the section Organizing test code.

The final block shows a simple way to run the tests. unittest.main() provides a command-line interface to the test script. When run from the command line, the above script produces an output that looks like this: