备用帖子1Shell(Shell R语言)

shell==========================

ls -lrt ### list fils by date (sort by date)

echo 1 > /proc/sys/vm/drop_caches 清理内存 free -m

du -h --max-depth=1  folder

How to move all files and folders via mv command [duplicate]
mv /path/sourcefolder/* /path/destinationfolder/

cp -r /path/to/directory /path/to/location/new-name

awk '$0 ~ ">hsa" { print $0; getline str; print str; } ' 20150417.fa

只取文件名:

ll *tsv | sed 's/.*://g' | sed 's/.* //g'

R: letters[1:26]

echo -en "\007" #beep
echo "echo -en '\007'" >> t.sh

=CHAR(96+ROW())

 xxx.sh >00.logs 2>&1  &

join -a 1 file1 file2 > mergedfile

#sort the bam files by name
for f in *.bam; do samtools sort -n "$f" "${f%.*}".sorted; done
#convert bam to sam
for f in *sorted.bam; do samtools view "$f" > "${f%.*}".sam; done
#convert sam to read counts
for f in *.sam; do python -m HTSeq.scripts.count "$f" Mus_musculus.GRCm38.75.gtf > "${f%.*}".readcount.txt ; done

split -l 2000 seq_2  -d -a 2  split_  按行拆分文件

sed '1i "geneid"' filename 插入一行内容在第一行

sed -i '1iabc' urfile  插入一行内容在第一行

-S <作业名称>  指定screen作业的名称。

 grep -A 1  'EN03347'   ripts.fa 输出匹配的行及其下一行
# screen -X quit  退出screen

# awk '{if(length($3)>30)print $0}' urfile

awk分割信息后获取最后一列 cat $(ll /home/sdzw/tcf/20110914_001/|awk '{print $NF}')|grep "abc"

 echo "Cfoo'barxml" | sed "s/'/::/g" |  sed 's/::/\\:/g' |  sed "s/:/'/g"    替换单引号为 \'

rpm -qa | grep mysql  // 这个命令就会查看该操作系统上是否已经安装了mysql数据库

grep -n 'key' file  显示行号

sed -n '1,5p' file

exit 0; 成功,退出脚本;

exit 1; 失败,退出脚本;

dos2unix filename 用:set ff=unix把它强制为unix格式   
sed -n '100,200p' mysql_slow_query.log 只查看文件的第100行到第200行

awk '$7=="." {print $0}' merged.gtf

awk '$7!="." {print $0}' merged.gtf

find ./ -name '*extractfastabyid*' -print

grep -wq "Run complete" ERR266361.err && echo "SRR000000 tophat 运行正常; "  || echo "SRR000000  tophat 运行错误; "


nohup command > myout.file 2>myerr &  使用 jobs 查看任务。使用 fg %n 关闭。

ps aux | grep pbs
pkill "pbs_*"
pbs_server
pbs_sched
pbs_mom
pbsnodes -a
echo 'sleep 20' | qsub
qmgr -c 'print server'
cat /var/spool/torque/server_name

 grep 'exon_number \"1\"' /filename | wc

grep -v 'ENS4810'   file   不包含ENS4810 的行

sed -e 's/abc//g' file

:set list    进入List Mode;:set nolist    退出List Mode

awk 'NR==FNR{a[FNR]=$0} NR>FNR{for(i in a)if($0~a[i]){print;getline;print}}' Aid Bfilt >Cnew

 

 

R==========================

do.call('rbind',strsplit( as.character(one$tr) ,split='_'))

     b1=paste(triples[,1],triples[,2],triples[,3],sep='_')     

expr[expr$cell_type =="hesc",]
expr[expr$cell_type %in% c("hesc","bj fibroblast"),]
subset(expr, cell_type =="hesc")
subset(expr, cell_type %in% c("bj fibroblast","hesc"))

data(mtcars)
mtcars[mtcars[, "mpg"]>25, ]
mtcars[mtcars$mpg>25, ]
subset(mtcars, mpg>25)
colnames(data)[2] <- 'column 2'
colnames(data) <- c( 'col 1', 'col 2', 'col 3')

install.packages("ggplot2")

sample()函数可以用于在特定群体中,随机 选取特定数目的个体。即随机抽样。

sample(x, size, replace = FALSE, prob = NULL) replace=F,表示不重复抽样 replace=T 表示可以重复抽样

R:fileConn<-file(pbs_file_name)
writeLines(str, fileConn)
close(fileConn)

R:x=c("aa","bb","cc")

for (i in 1:length(x))
{
   str=x[i]
   cat(str)
}

subset(dataset, gender=="M" | age < 50)
DF.new <- subset(DF, (gender == "female") & (age > 50))
May be this help you; Just intall.packages("sqldf", dependencies=T)
require(sqldf)
my_df<-data.frame(cbind(gender=sample(c("male","female"),50,replace=T),
age=round(rnorm(50, mean=30, sd=5),0)))
my_df_subset_male<-sqldf("select * from my_df where gender=='male'")
my_df_subset_male_greater35<-sqldf("select * from my_df where gender=='male'
and age>35")
df[,c('sequence','start','end')]
df[grep("trna", df$common_name, ignore.case=T),]
a[rownames(a)=='a',]
http://code.google.com/p/sqldf/
filter<-fpkm$geneid %in% df.ids$id
df.new<-fpkm[filter,]

dev.new(width=5, height=4)  #窗口大小尺寸
 
http://www.cnblogs.com/emanlee/p/3332493.html
 
posted @ 2013-12-17 12:12  emanlee  阅读(1385)  评论(0编辑  收藏  举报