调整台清屏 Ctrl+L Command+L,对bed文件进行评释

   
许多时候,大家须要对抽取的SNV实行疏解,这一年恐怕会在大切诺基上进行疏解,平时注释文件都包蕴Chr(染色体)、Start(起第一个人点)、End(截止位点)、Description(描述),而小编辈的SNV文件一般是全数Position(位置),因而大家能够先固定Chr,再用Postion去稳固到Start和End之间,找到相对应的Description。为了加快捷度,能够运用二分查找法。

转发:

 1 for (value in dt$value){
 2 #df:data.frame, V1 and V2 should be Start and End   value: Postition  used to find region  return:df row number where position locates  ,if no region return -1
 3     low=1
 4     high=nrow(df)
 5     mid=high %/% 2
 6     if (df[low,1] <= value & value <= df[low,2]) low
 7     else if (df[high,1] <= value & value <= df[high,2]) high
 8     else{
 9     while (value > df[mid,2] || value < df[mid,1]){
10       if (value > df[mid,2]){
11         low = mid+1
12       } else if (value < df[mid,1]) {
13         high = mid - 1
14       } 
15       if(high<low){
16          mid=-1;break
17       }
18       mid=(low+high)%/%2
19     }
20       mid
21 }
22 }

途睿欧语言  MuranoStudio连忙键总计

在安德拉中选取for循环效用低,因而也得以用data.table包的foverlap函数,立异代码如下,对bed文件实行评释,假设要对snv举办注明,只供给将snv改成相应的start和end相等的bed文件就能够。

一、控制台

 1 #!/bin/Rscript
 2 
 3 library(data.table)
 4 
 5 arg <- commandArgs(T)
 6 if (length(arg) != 3) {
 7     message("[usage]: BedAnnoGene.R bedfile gtffile outputfile")
 8     message("    bedfile format: chr start end information(Arbitrary but can not be lacked)")
 9     message("    GTFfile: gtf file downloaded from GENCODE")
10     message("    outputfile: file to be writen out")
11     message("    needed package: data.table 1.10.4")
12     stop("Please check your arguments!")
13 }
14     
15 bedfile <- arg[1]
16 annofile <- arg[2]
17 outfile <- arg[3]
18 
19 #read file 
20 anno <- fread(annofile,sep="\t",header=F)
21 bed <- fread(bedfile,sep="\t",header=F)
22 setnames(anno,c("V1","V2","V3","V4","V5","V9"),c("Chr","Gene","Type","Start","End","Info"))
23 anno <- anno[Type=="gene",.(Chr,Start,End,Gene=sapply(strsplit(tstrsplit(Info,";")[3][[1]],"\""),function(x)x[2]))]
24 setkey(anno,Chr,Start,End)
25 setkey(bed,V1,V2,V3)
26 
27 #find overlaps by Chr
28 lst <- list()
29 for (ChrI in intersect(unique(bed$V1),unique(anno$Chr))){
30   anno_reg <- anno[Chr == ChrI,.(Start,End)]
31   bed_reg <- bed[V1 == ChrI,.(V2,V3)]
32   setkey(anno_reg,Start,End)
33   setkey(bed_reg,V2,V3)
34   overl <- foverlaps(bed_reg,anno_reg,which=TRUE,nomatch = 0)
35   if (nrow(overl) > 0){
36     lst[[ChrI]] <- data.table(Chr=ChrI,bed[V1 == ChrI,][overl[["xid"]],.(V2,V3,V4)],anno[Chr == ChrI][overl[["yid"]],.(Gene)])
37   }
38 }
39 merge_dt <- rbindlist(lst)
40 setnames(merge_dt,c("V2","V3","V4"),c("Start","End","Name"))
41 
42 #if one region has more than one gene
43 torm <- list()
44 for (i in 1:(nrow(merge_dt)-1)){if(merge_dt[i,"Name"]==merge_dt[i+1,"Name"]){set(merge_dt,i+1L,ncol(merge_dt),paste(merge_dt[i,"Gene"],merge_dt[i+1,"Gene"],sep=";"));torm <- c(torm,list(i))}}
45 torm <- unlist(torm)
46 merge_dt <- merge_dt[-torm,]
47 
48 fwrite(merge_dt,file=outfile)

功能  Windows & Linux   Mac

应用辅助能够在自身github看到   https://github.com/yiliu4234/BedAnnoGene

移动鼠标到调控台 Ctrl+2 Ctrl+2

 

活动到鼠标命令编辑  Ctrl+1  Ctrl+1

支配台清屏 Ctrl+L Command+L

移动鼠标至第一行 Home Command+Left

活动鼠标至最后一行 End Command+Right

历史记录翻滚 Up/Down Up/Down

弹出历史记录栏 Ctrl+Up Command+Up

停下目前命令 Esc Esc

改动专门的学问路径 Ctrl+Shift+K Ctrl+Shift+K

二、代码区

功能     Windows & Linux      Mac

运动鼠标到文件找出区 Ctrl+. Ctrl+.

挪动鼠标至文件编辑区 Ctrl+1 Ctrl+1

新文档(chrome除外) Ctrl+Shift+N Command+Shift+N

展开文书档案 Ctrl+O Command+O

封存当前文书档案 Ctrl+S Command+S

关闭当前文书档案(chrome除却) Ctrl+W Command+W

闭馆当前文书档案(chrome) Ctrl+Shift+Z Command+Shift+Z

关门全体文书档案 Ctrl+Shift+W Command+Shift+W

预览HTML Ctrl+Shift+Y Command+Shift+Y

转换为HTML Ctrl+Shift+H Command+Shift+H

编译PDF (TeX and Sweave) Ctrl+Shift+I Command+Shift+I

插入块 Ctrl+Alt+I Command+Option+I

布置代码块 Ctrl+Shift+昂Cora Command+Shift+猎豹CS6

运作当前行 Ctrl+Enter Command+Enter

再度运维业前区 Ctrl+Shift+P Command+Shift+P

运行当前文书档案 Ctrl+Alt+宝马X3 Command+Option+Koleos

从起先运营至当下行 Ctrl+Alt+B Command+Option+B

从日前行运维至结尾 Ctrl+Alt+E Command+Option+E

运行当前函数定义 Ctrl+Alt+F Command+Option+F

运作当前块 Ctrl+Alt+C Command+Option+C

运作下一个块 Ctrl+Alt+N Command+Option+N

实践一个文书 Ctrl+Shift+O Command+Shift+O

试行业前文书档案 Ctrl+Shift+S Command+Shift+S

推行当前文档并且展现 Ctrl+Shift+Enter Command+Shift+Enter

折叠选项 Alt+L Command+Option+L

开拓选项 Shift+Alt+L Command+Shift+Option+L

折叠全体 Alt+0 Command+Option+0

开发装有 Shift+Alt+0 Command+Shift+Option+0

前往行 Shift+Alt+G Command+Shift+Option+G

跳至 Shift+Alt+J Command+Shift+Option+J

换页 Ctrl+Alt+Down Ctrl+Option+Down

前一页 Win: Ctrl+Alt+Left, Linux: Ctrl+PageUp Ctrl+Option+Left

后一页 Win: Ctrl+Alt+Right, Linux: Ctrl+PageDown Ctrl+Option+Right

第一页 Ctrl+Shift+Alt+Left Ctrl+Shift+Option+Left

谈起底一页 Ctrl+Shift+Alt+Right Ctrl+Shift+Option+Right

往回导航 Ctrl+F9 Command+F9

向前导航 Ctrl+F10 Command+F10

行缩进 Ctrl+I Command+I

从选拔中抽出函数 Ctrl+Shift+U Command+Shift+U

评释/撤除注释当前行 Ctrl+Shift+C Command+Shift+C

重复讲明 Ctrl+Shift+/ Command+Shift+/

Transpose Letters Ctrl+T

Move Lines Up/Down Alt+Up/Down Option+Up/Down

Copy Lines Up/Down Ctrl+Alt+Up/Down Command+Option+Up/Down

Jump to Matching Brace/Paren Ctrl+P Ctrl+P

Find and Replace Ctrl+F Command+F

Find Next Win: F3, Linux: Ctrl+G Command+G

Find Previous Win: Shift+F3, Linux: Ctrl+Shift+G Command+Shift+G

Replace and Find Ctrl+= Command+=

Find in Files Ctrl+Shift+F Command+Shift+F

Check spelling F7 F7

三、Editing (Console and Source)

Description  Windows & Linux    Mac

Undo Ctrl+Z Command+Z

Redo Ctrl+Shift+Z Command+Shift+Z

Cut Ctrl+X Command+X

Copy Ctrl+C Command+C

Paste Ctrl+V Command+V

Select All Ctrl+A Command+A

Jump to Word Ctrl+Left/Right Option+Left/Right

Jump to Start/End Ctrl+Home/End or Ctrl+Up/Down Command+Home/End or
Command+Up/Down

Delete Line Ctrl+D Command+D

Select Shift+[Arrow] Shift+[Arrow]

Select Word Ctrl+Shift+Left/Right Option+Shift+Left/Right

Select to Line Start Shift+Home Command+Shift+Left or Shift+Home

Select to Line End Shift+End Command+Shift+Right or Shift+End

Select Page Up/Down Shift+PageUp/PageDown Shift+PageUp/Down

Select to Start/End Ctrl+Shift+Home/End or Shift+Alt+Up/Down
Command+Shift+Up/Down

Delete Word Left Ctrl+Backspace Option+Backspace or
Ctrl+Option+Backspace

Delete Word Right Option+Delete

Delete to Line End Ctrl+K

Delete to Line Start Option+Backspace

Indent Tab (at beginning of line) Tab (at beginning of line)

Outdent Shift+Tab Shift+Tab

Yank line up to cursor Ctrl+U Ctrl+U

Yank line after cursor Ctrl+K Ctrl+K

Insert currently yanked text Ctrl+Y Ctrl+Y

Insert assignment operator Alt+- Option+-

Show help for function at cursor F1 F1

Show source code for function at cursor F2 F2

Completions (Console and Source)

Description Windows & Linux Mac

Attempt completion Tab or Ctrl+Space Tab or Command+Space

Navigate candidates Up/Down Up/Down

Accept selected candidate Enter, Tab, or Right Enter, Tab, or Right

Dismiss completion popup Esc Esc

四、Views

Description Windows & Linux Mac

Goto File/Function Ctrl+. Ctrl+.

Move cursor to Source Editor Ctrl+1 Ctrl+1

Move cursor to Console Ctrl+2 Ctrl+2

Move focus to Help Ctrl+3 Ctrl+3

Show History Ctrl+4 Ctrl+4

Show Files Ctrl+5 Ctrl+5

Show Plots Ctrl+6 Ctrl+6

Show Packages Ctrl+7 Ctrl+7

Show Workspace Ctrl+8 Ctrl+8

Show Git/SVN Ctrl+9 Ctrl+9

Show Build Ctrl+0 Ctrl+0

Sync Editor and PDF Preview Ctrl+F8 Command+F8

五、Build

Description Windows & Linux Mac

Build and Reload Ctrl+Shift+B Command+Shift+B

Load All (devtools) Ctrl+Shift+L Command+Shift+L

Check Package Ctrl+Shift+E Command+Shift+E

六、Plots

Description Windows & Linux Mac

Previous plot Ctrl+Shift+PageUp Command+Shift+PageUp

Next plot Ctrl+Shift+PageDown Command+Shift+PageDown

Show manipulator Ctrl+Shift+M Command+Shift+M

七、Git/SVN

Description Windows & Linux Mac

Diff active source document Ctrl+Shift+D Command+Shift+D

Commit changes Ctrl+Shift+M Command+Shift+M

Scroll diff view Ctrl+Up/Down Ctrl+Up/Down

Stage/Unstage (Git) Spacebar Spacebar

Stage/Unstage and move next (Git) Enter Enter

相关文章