06 2022 档案
摘要:001、 pbmc <- NormalizeData(pbmc) 002、实现过程 dat <- pbmc[["RNA"]]@counts dat <- as.data.frame(dat) for (i in 1:ncol(dat)) { dat[,i] <- log1p(dat[,i]/sum(
阅读全文
摘要:001、直接输入函数 library(qqman) ## 加载包 manhattan ## 直接再终端输入函数名称回车,即可显示源代码 002、在Rstudio中,在终端中选中函数, 按f2 library(qqman) manhattan ## 选中函数名, 按f2 003、fix(函数名)或者
阅读全文
摘要:001、 a <- c(3, 4, 3, 1) b <- c(1, 2, 5, 4) c <- c(3, 1, 2, 7) dat <- data.frame(a, b, c) dat colSums(dat) ## 求和 rowSums(dat) colMeans(dat) ## 平均值 rowM
阅读全文
摘要:001、 packages <- c("data.table", "ggplot2", "qqman", "detectRUNS") ## 确保包已经安装 sapply(packages, require) sapply(packages, require, character.only = TRU
阅读全文
摘要:001、应用于数据框 a <- c(2, 3, 6) b <- c(5, 2, 2) c <- c(4, 5, 1) dat <- data.frame(a, b, c) dat sapply(dat, sum) ## 对列进行循环, 求和, 返回向量 002、应用于列表 a <- c(3, 4,
阅读全文
摘要:001、substr str <- "werewrt" ## 测试字符串 substr(str, 1, 3) ## 提取1-3字符 substr(str, 3) ## 必须指定起始 substr(str, 2, 2) ## 提取单个字符 002、substring str <- "werewrt"
阅读全文
摘要:1、awk + >>追加实现 for i in $(seq 2 $(head -n 1 a.txt | awk '{print NF}')); do cut -f 1,$i a.txt | awk 'BEGIN{sum =0 } {if(NR != 1) sum += $2} {if($1 ~ /^
阅读全文
摘要:001、 dir() ## 直接输出 pdf("001.pdf") plot(1:10, xlab = "测试") dev.off() library(sysfonts) ## 给输出的pdf文件增加中文 library(showtext) font_add("myFont1", "timesbd.
阅读全文
摘要:001、 root@ubuntu2204:/home/test# ls a.txt root@ubuntu2204:/home/test# cat a.txt ## 测试数据 2324 5534 jkh sdff root@ubuntu2204:/home/test# sed 's/**/Q/' a
阅读全文
摘要:001、加载包测试 library(data.table) library(ggplot2) library(dplyr) library(Seurat) library(patchwork) 002、批量安装R包 packages <- c("data.table", "ggplot2", "dp
阅读全文
摘要:1、找到python IDLE安装目录(我这里是:C:\Users\jim\AppData\Local\Programs\Python\Python310\Lib\idlelib) 在该目录下增加文件:ClearWindow.py 文件内容如下: """ Clear Window Extension
阅读全文
摘要:001、生成数组, 生成数组a root@ubuntu2204:/home/test# a[0]=800 root@ubuntu2204:/home/test# a[1]=500 root@ubuntu2204:/home/test# a[2]="kkk" root@ubuntu2204:/home
阅读全文
摘要:001、问题 002、搜索Windows PowerShell 003、 以管理员身份执行如下代码:Get-AppxPackage Microsoft.SecHealthUI -AllUsers | Reset-AppxPackage 04、重启计算机
阅读全文
摘要:001、问题如下: 002、解决方法 003、 004、 005、
阅读全文
摘要:001、 root@PC1:/home/test3# cat a.txt 1 2 3 4 5 root@PC1:/home/test3# cat b.txt test01 test02 test03 test04 test05 root@PC1:/home/test3# cat test.r lib
阅读全文
摘要:001、 dir() ped1 <- read.table("test.ped") ped1 ped2 <- read.table("test.ped", colClasses = "character") ## 增加该参数 ped2
阅读全文
摘要:001、求每列的和 root@PC1:/home/test2# ls a.txt root@PC1:/home/test2# cat a.txt 3 5 2 4 1 3 5 5 2 3 8 3 root@PC1:/home/test2# awk '{for(i = 1; i <= NF; i++)
阅读全文
摘要:001、求每列的和 root@PC1:/home/test2# ls a.txt root@PC1:/home/test2# cat a.txt ## 测试数据 3 5 2 4 1 3 5 5 2 3 8 3 root@PC1:/home/test2# for i in $(seq $(head -
阅读全文
摘要:1、001 root@PC1:/home/test2# ls a.txt root@PC1:/home/test2# cat a.txt 1 e d 3 w e root@PC1:/home/test2# awk '{if($0 != "") {i = 0} else {i++}} END {pri
阅读全文
摘要:001、 root@PC1:/home/test2# ls a.txt root@PC1:/home/test2# cat a.txt 3 w e 1 e d root@PC1:/home/test2# cat -A a.txt $ $ 3 w e$ $ 1 e d$ root@PC1:/home/
阅读全文
摘要:1、 root@PC1:/home/test3# ls a.txt root@PC1:/home/test3# cat a.txt 1 e d 2 a g 3 w e 4 d g 5 g j 6 e j 7 l m 8 i n root@PC1:/home/test3# a=3 ## 行号 3 ro
阅读全文
摘要:001、sed实现 root@PC1:/home/test2# ls a.txt root@PC1:/home/test2# cat a.txt 1 e d 2 a g 3 w e 4 d g 5 g j 6 e j 7 l m 8 i n root@PC1:/home/test2# sed 'N;
阅读全文
摘要:1、1、3行互换 root@PC1:/home/test2# ls a.txt swap.sh root@PC1:/home/test2# cat a.txt 1 x c 2 s d 3 e t 4 d s 5 j u 6 n x root@PC1:/home/test2# cat swap.sh
阅读全文
摘要:1、001 root@PC1:/home/test2# ls a.txt root@PC1:/home/test2# cat a.txt Chr1 Chr11 Chr7 Chr8 Chr10 Chr2 Chr5 Chr3 root@PC1:/home/test2# sort a.txt ## 排序异
阅读全文
摘要:01、 root@PC1:/home/test2# ls a.txt root@PC1:/home/test2# cat a.txt ddd 2 8 aa 1 87 name gender score ff 2 3 ss 1 23 root@PC1:/home/test2# sort -k 3 a.
阅读全文
摘要:1、临时创建 root@PC1:/home/test2# ls a.txt root@PC1:/home/test2# cat a.txt j k e s f g x v b root@PC1:/home/test2# alias 'cat=cat -A' ## 创建命令别名 root@PC1:/h
阅读全文
摘要:1、提取 包含s的列 dir() dat <- read.table("a.txt") dat ## 测试数据 idx <- dat[1,] == "s" idx for (i in 2:nrow(dat)) { temp <- dat[i,] == "s" idx <- idx | temp ##
阅读全文
摘要:001、测试数据 root@PC1:/home/test# ls a.txt root@PC1:/home/test# cat a.txt 1 2 3 4 5 6 7 8 9 e f s f g u d f x a d s g s c s e s z c b e g c s d f 002、提取包含
阅读全文
摘要:1、 dat <- matrix(c(3, 7, 1, 2, 4, 9, 8, 5, 0, 15, 22, 77, 11, 44, 33, 88), nrow = 4) dat lines <- nrow(dat) * (nrow(dat) - 1)/2 + nrow(dat) lines res
阅读全文
摘要:1、系统信息 root@ubuntu2204test01:~# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04 LTS Release: 22.04 Coden
阅读全文
摘要:1、系统信息 root@ubuntu2204test01:/home# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04 LTS Release: 22.04 C
阅读全文
摘要:1、系统信息 root@ubuntu2204test01:/home# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04 LTS Release: 22.04 C
阅读全文
摘要:1、系统信息 root@ubuntu2204test01:~# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04 LTS Release: 22.04 Coden
阅读全文
摘要:001、问题 root@PC1:/home/software# gdebi rstudio-server-2022.02.3-492-amd64.deb Reading package lists... Done Building dependency tree... Done Reading st
阅读全文
摘要:1、 root@PC1:/home/test# ls a.txt root@PC1:/home/test# cat a.txt | tee xx.txt ## 输出屏幕的结果 保存至xx.txt dd ff ii xx jj ee xx vv mm root@PC1:/home/test# ls a
阅读全文
摘要:1、基本用法 wget https://s3.amazonaws.com/plink1-assets/plink_linux_x86_64_20220402.zip 2、指定下载目录 wget -P /home/test2/ https://s3.amazonaws.com/plink1-asset
阅读全文
摘要:001、 a = NA ## NA表示这个位置的值为空 b = "" ## ""表示空字符串 c = NULL ## NULL表示变量为空 a b c class(a) ## 逻辑类型 class(b) ## 字符类型 class(c) ## NULL类型 length(a) ## 长度为1 len
阅读全文
摘要:001、 函数原型: %||%函数一共有两个参数: 当x为空时,返回y, x不为空时,返回x。 library(rlang) 1 %||% 2 NULL %||% 2 ## 这里的空值只识别 NULL。 "" %||% 2 NA %||% 2
阅读全文
摘要:判断逻辑向量是否至少一个为真或者全部为真。 1、 any(c(FALSE, FALSE, FALSE)) ## 任何一个为真,则为真 any(c(FALSE, FALSE, TRUE)) any(c(TRUE, TRUE, TRUE)) all(c(TRUE, TRUE, TRUE)) ## 全部为
阅读全文
摘要:001、 switch ("a", ## 匹配a "a" = 1:5, "b" = 3:8, "c" = 100-110 ) switch ("b", ## 匹配b "a" = 1:5, "b" = 3:8, "c" = 100-110 ) switch ("c", ## 匹配c "a" = 1:5
阅读全文
摘要:1、测试数据下载:ftp://ftp.ensemblgenomes.org/pub/plants/release-44/gff3/arabidopsis_thaliana/Arabidopsis_thaliana.TAIR10.44.chromosome.1.gff3.gz 2、 [root@PC1
阅读全文
摘要:001、测试数据 [root@PC1 test2]# ls a.fa test.py [root@PC1 test2]# cat a.fa ## 测试数据 >OR4F5_ENSG00000186092_ENST00000641515_61_1038_2618 CCCAGATCTCTTCAGTTTTT
阅读全文
摘要:001、 [root@PC1 test2]# ls a.txt b.txt test.py x.csv y.csv [root@PC1 test2]# pwd /home/test2 [root@PC1 test2]# cat test.py ## 脚本 #!/usr/bin/python impo
阅读全文
摘要:1、合并txt文件 [root@PC1 test2]# ls a.txt b.txt c.txt test.py x.csv y.csv [root@PC1 test2]# cat a.txt a a a b b b [root@PC1 test2]# cat b.txt c c c d d d [
阅读全文
摘要:1、 直接看例子 a <- c(3, 5, 3, 1, 4, 2) b <- c(10, 50, 60, 70, 80, 40) c <- c("a", "a", "b", "b", "c", "c") dat <- data.frame(a, b, c) dat ## 测试数据 tapply(da
阅读全文
摘要:1、c函数实现 dat <- matrix(sample(1:9, 15, replace = T), nrow = 3) dat c(dat) ## 逐列转换为向量 c(t(dat)) ## 逐行转换为向量 2、for循环实现 dat <- matrix(sample(1:9, 15, repla
阅读全文
摘要:1、 a <- runif(10) ## 在0到1之间取出10个复合均匀分布的随机数 b <- sample(1:3, 10, replace = T) ## 在1-3中取出10个随机数 a b split(a, b) ## 对a按照b为列表名进行归类
阅读全文
摘要:R语言中runif函数:默认生成0-1之间符合均匀分布的随机数。 1、 a <- runif(10) ## 生成10个0-1之间的符合正态分布的随机数 a mean(a) b <- runif(20) ## 20个 b mean(b) 2、设定范围 a <- runif(10, 0, 100) ##
阅读全文
摘要:数据来源:https://www.jianshu.com/p/4f7aeae81ef1 1、 library(dplyr) library(Seurat) library(patchwork) # Load the PBMC dataset pbmc.data <- Read10X(data.dir
阅读全文
摘要:1、内置函数remove >>> a = set([100, 200, 300]) >>> a {200, 100, 300} >>> type(a) <class 'set'> >>> a.remove(200) ## 内置函数remove删除指定元素 >>> a {100, 300} 2、清空集
阅读全文
摘要:1、内置函数add >>> a = {4, 5} >>> a {4, 5} >>> type(a) <class 'set'> >>> a.add(100) ## 利用内置函数add添加元素 >>> a {100, 4, 5} >>> a.add(500) >>> a {100, 500, 4, 5
阅读全文
摘要:1、利用键索引直接添加 >>> dict1 = dict(zip(["aa", "bb", "cc"], [100, 200, 300])) >>> dict1 {'aa': 100, 'bb': 200, 'cc': 300} >>> dict1["dd"] = 400 ## 利用键索引直接添加
阅读全文
摘要:1、利用内置函数pop删除 >>> dict1 = dict(a = 100, b = 200, c = 300, d = 400, e = 500) >>> dict1.pop("b") ## 内置函数pop删除,需指定键 200 >>> dict1 {'a': 100, 'c': 300, 'd
阅读全文
摘要:001、update函数合并 >>> a = {"aaa":100, "bbb":200, "ccc":300} >>> a {'aaa': 100, 'bbb': 200, 'ccc': 300} >>> b = dict(ccc = 400, ddd = 500, eee = 600) >>>
阅读全文
摘要:1、 a <- c(20, 10, 40, 80, 50) which.max(a) ## 返回最大值的索引 which.min(a) ## 返回最小值的索引
阅读全文
摘要:1、 start <- Sys.time() ## 记录 Sys.sleep(20) ## 停止20s end <- Sys.time() ## 记录 elapse <- end - start ## 计算 print(elapse) ## 打印 2、 start <- Sys.time() Sys
阅读全文
摘要:001、直接使用花括号 >>> dict1 = {"aaa":100, "bbb":200, "ccc":300} ## 每一项包括键和值,中间用冒号连接 >>> dict1 {'aaa': 100, 'bbb': 200, 'ccc': 300} >>> type(dict1) <class 'd
阅读全文
摘要:001、enumerate: >>> a = ["xx", "aa", "tt", "cc"] >>> a ['xx', 'aa', 'tt', 'cc'] >>> for i in enumerate(a): ## enumerate返回可迭代对象的索引值,生成二元组 ... print(i) .
阅读全文
摘要:1、⾃我理解:泛型函数就是,你定义函数时候,是万能类型。在调⽤的时候,只要你把具体的类型传进去就好。好处呢,就是代码的复⽤,减少代码量。(c语言中函数的参数需要固定参数类型。)
阅读全文
摘要:1、 在矩阵中,若数值为0的元素数目远远多于非0元素的数目,并且非0元素分布没有规律时,则称该矩阵为稀疏矩阵; 与之相反,若非0元素数目占大多数时,则称该矩阵为稠密矩阵。
阅读全文
摘要:1、将文本中的所有d替换为QQ [root@PC1 test3]# ls a.txt test.py [root@PC1 test3]# cat a.txt erg iuy dfg fdf er4 435 dft 34f cgd err [root@PC1 test3]# cat test.py #
阅读全文
摘要:1、删除第一列 [root@PC1 test3]# ls a.txt test.py [root@PC1 test3]# cat a.txt 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2
阅读全文
摘要:1、 \s表示空白字符。 \S表示非空白字符。 [root@PC1 test]# ls a.txt [root@PC1 test]# cat a.txt a abckf ff b dfabc fd c abc drfd d df.abcfd fd e df~abc dr f abc.df fd g
阅读全文
摘要:001、问题 [root@PC1 test]# ls a.txt [root@PC1 test]# cat a.txt ## 测试数据 73 dar 87 32 dar.3 fdg fd dar-5 dg df dar~df gfdg df ee.dar 34 er fd-dar 767 df df
阅读全文
摘要:1、 >>> a = list(range(0, 11)) ## 列表 >>> a [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> import numpy as np >>> np_a = np.array(a) >>> list(np_a[[1, 3, 7]]) #
阅读全文
摘要:1、删除第1行 [root@PC1 test2]# ls a.txt test.py [root@PC1 test2]# cat a.txt 01 11 21 31 02 12 22 32 03 13 23 33 04 14 24 34 05 15 25 35 06 16 26 36 [root@P
阅读全文
摘要:1、提取第一列 [root@PC1 test2]# ls a.txt test.py [root@PC1 test2]# cat a.txt ## 测试数据 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
阅读全文
摘要:1、问题 [root@PC1 test2]# pip install numpy bash: pip: command not found... 2、系统 [root@PC1 test2]# cat /etc/system-release Rocky Linux release 8.5 (Green
阅读全文
摘要:数据来源:https://www.jianshu.com/p/4f7aeae81ef1 1、 pbmc <- NormalizeData(pbmc) dat <- pbmc[["RNA"]]@counts ## 原始数据 dat <- as.data.frame(dat) dat2 <- matri
阅读全文
摘要:1、 [root@PC1 test3]# ls a.txt [root@PC1 test3]# cat a.txt ## 测试数据 8.34565 3.23445 7.32423 0 8.343532523 5.34355 3.355623253 0 0 [root@PC1 test3]# awk
阅读全文
摘要:1、 >>> a = [111, 222, 333] >>> "-".join(a) ## 数值类型报错 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: sequence item 0
阅读全文
摘要:1、 [root@PC1 test2]# ls a.txt test.py [root@PC1 test2]# cat a.txt ## 测试数据 dsfs JHDSF ADFD dfesr fKHJ FJfdf [root@PC1 test2]# cat test.py ## 转换程序 #!/us
阅读全文
摘要:1、输出文本的前三行 [root@PC1 test2]# ls a.txt test.py [root@PC1 test2]# cat a.txt ## 测试数据 1 u j d 2 s f f 3 z c e 4 z v k 5 c f y 6 w q r 7 a d g 8 e f s [roo
阅读全文
摘要:1、 [root@PC1 test2]# ls a.txt b.txt test.sh [root@PC1 test2]# cat a.txt ## 测试数据 8 2 4 8 7 3 [root@PC1 test2]# cat b.txt 8 3 4 8 5 3 6 [root@PC1 test2]
阅读全文
摘要:1、 [root@PC1 test2]# ls a.txt [root@PC1 test2]# cat a.txt 8 4 2 2 8 3 1 3 4 3 4 6 [root@PC1 test2]# awk 'BEGIN{a = 0} {print $1 - a; a = $1}' a.txt ##
阅读全文
摘要:001、 1、矩阵转换为三元组 num <- c(5, 2, 7, 0, 9, 3, 4, 2, 3, 1, 7, 8) dat <- matrix(num, nrow = 3, ncol = 4, byrow = T) dat rows <- rep(1:nrow(dat), each = nco
阅读全文
摘要:1、输出列的累加和 [root@PC1 test2]# ls a.txt [root@PC1 test2]# cat a.txt 8 4 2 2 8 3 1 3 4 3 4 6 [root@PC1 test2]# awk '{sum += $1} {print sum}' a.txt ## 第一列累
阅读全文
摘要:001、删除含有空值的行 a <- c(3, NA, 4, 7, NA, 8) b <- c(1:2, NA, 3:5) c <- c(NA, "a", "k", "b", "c", "d") dat <- data.frame(a, b, c) dat na.omit(dat) ## 删除所有有空
阅读全文