目标:使用R脚本从ensembl上下载transcript数据

简单粗暴,直接上代码。biomaRt的介绍晚一点更新。

# this file helps extract information from ensembl with gene name as input
# 11/02/2018, pxy7896 library(biomaRt) # 使用参数
# args=commandArgs(T)
# 从文件读取
geneNamesFile <- "geneNames.txt"
otherInfoFile <- "otherInfo.txt" raw <- read.table(geneNamesFile, col.names = c("geneNames"), stringsAsFactors = FALSE)
# geneNames is character
geneNames <- raw[["geneNames"]]
#geneNames <- args[1]
otherInfo <- read.table(otherInfoFile, stringsAsFactors = FALSE)
dataSet <- otherInfo[[1]][1]
# choose database
#dataSet <- args[2]
mart = useMart("ensembl", dataset=dataSet)
attr <- c("hgnc_symbol", "ensembl_transcript_id", "chromosome_name", "transcript_start", "transcript_end")
# get transcript ids
ids <- getBM(attributes = attr, filters = "hgnc_symbol", values = geneNames, mart = mart)
write.table(ids, "ids.txt", sep="\t", quote=FALSE, row.names=FALSE)
targetIds <- ids["ensembl_transcript_id"]
# get exons info
exonAttr <- c("5_utr_start","5_utr_end","3_utr_start","3_utr_end","strand", "ensembl_transcript_id", "ensembl_exon_id", "exon_chrom_start", "exon_chrom_end")
#attr2 <- c(attr, exonAttr)
result <- getBM(attributes = exonAttr, filters = "ensembl_transcript_id", values = targetIds, mart = mart)
write.table(result, args[4], sep = "\t", quote = FALSE, row.names=FALSE)

  

R-biomaRt使用-代码备份的更多相关文章

  1. 随机森林入门攻略(内含R、Python代码)

    随机森林入门攻略(内含R.Python代码) 简介 近年来,随机森林模型在界内的关注度与受欢迎程度有着显著的提升,这多半归功于它可以快速地被应用到几乎任何的数据科学问题中去,从而使人们能够高效快捷地获 ...

  2. 博客使用的CSS代码备份

    CSS代码备份 /*simplememory*/ #google_ad_c1, #google_ad_c2 { display: none; } .syntaxhighlighter a, .synt ...

  3. 1.svn 彻底clear时,注意代码备份 2.借助vc助手加头文件

    1.svn 彻底clear时,注意代码备份 2.不小心彻底clear可以在回收站找到 3.借助vc助手加头文件

  4. 决策树ID3原理及R语言python代码实现(西瓜书)

    决策树ID3原理及R语言python代码实现(西瓜书) 摘要: 决策树是机器学习中一种非常常见的分类与回归方法,可以认为是if-else结构的规则.分类决策树是由节点和有向边组成的树形结构,节点表示特 ...

  5. 同时将代码备份到Gitee和GitHub

    同时将代码备份到Gitee和GitHub 如何将GitHub项目一步导入Gitee 如何保持Gitee和GitHub同步更新 如何将GitHub项目一步导入Gitee 方法一: 登陆 Gitee 账号 ...

  6. 我的R代码备份

    1 #f1=scan(file="f1.txt");  2 #f2=scan(file="f2.txt");  3 f=scan(file="5.2_ ...

  7. Android短信管家视频播放器代码备份

    自己保留备份,增强记忆   这是video的类 public class VideoActivity extends Activity { /** * 解析网络页面 */ private WebVie ...

  8. [Python]南邮OJ代码备份爬虫

    之前看过Python学习的经验,说以project为导向学习. 自己分析了一下,一般接触Python的都有一定的其它语言基础,对于程序设计的基本逻辑,语法都有一个大概的了解.而Python这样的脚本语 ...

  9. html和js基础功能代码备份

    1)贴图:<img src="图片地址">2)加入连接:<a href="所要连接的相关地址">写上你想写的字</a> 3) ...

随机推荐

  1. c# 父类的引用指向子类的实例

    在C#中关于父类对子类的引用大概有这么几种: 父类是接口,普通类,抽象类 public interface A { void a(); } public class B { public void b ...

  2. spring mvc改造成spring boot

    一.新增依赖: <dependency> <groupId>org.springframework.boot</groupId> <artifactId> ...

  3. (生产)animate.css 动画库

    官网:https://daneden.github.io/animate.css/ Animate.css是一个有趣的,跨浏览器的css3动画库 用法 首先引入animate css文件:    &l ...

  4. RESTful API设计基本原则

    REST四个基本原则:1.使用HTTP动词:GET POST PUT DELETE:2.无状态连接,服务器端不应保存过多上下文状态,即每个请求都是独立的:3.为每个资源设置URI:4.通过XML JS ...

  5. Design Pattern ->Abstract Factory

    Layering & Contract Philosophy With additional indirection Abstract Factory //The example code i ...

  6. [原创]在Debian9上配置NAS

    序言 此教程安装的都是最新版本的.由于是当NAS让它非常稳定的运行,所以能不安装的软件尽量不要安装. 一.准备工作 1. 更新系统 没啥,就他喵想用个最新的. apt update && ...

  7. Qt开发北斗定位系统融合百度地图API及Qt程序打包发布

    Qt开发北斗定位系统融合百度地图API及Qt程序打包发布 1.上位机介绍 最近有个接了一个小型项目,内容很简单,就是解析北斗GPS的串口数据然后输出经纬度,但接过来觉得太简单,就发挥了主观能动性,增加 ...

  8. 用户管理的设计--4.jquery的ajax实现登录名的校验

    页面效果 鼠标失去焦点时,不需要刷新页面进行校验,判断登录名是否重复. 实现步骤 1.引入struts2-json-plugin-2.5.10.1插件包 2.页面使用jquery的ajax实现后台校验 ...

  9. *15. 3Sum (three pointers to two pointers), hashset

    Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find ...

  10. AttributeError: module 'requests' has no attribute 'get' 遇到了这个错误,是因为我把python关键字做了包名。。。

    初学者总会犯各种低级错误,这是其一,特此记录.