Mercurial > repos > rnateam > nastiseq
comparison test-data/test.r @ 0:0a0bba8e1823 draft default tip
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/nastiseq commit 8b472e8680bb0ae5d11ee48b642ab305f9333a48
author | rnateam |
---|---|
date | Wed, 22 Feb 2017 07:32:08 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:0a0bba8e1823 |
---|---|
1 library(NASTIseq) | |
2 | |
3 ## generation of test set | |
4 # data(WholeRoot) | |
5 # WholeRoot$genepos$feature <- 'gene' | |
6 # | |
7 # set_attri <- function(attri){ | |
8 # attri = paste('gene_id ', '"', attri, '"', ';', sep = '') | |
9 # return(attri) | |
10 # } | |
11 # | |
12 # WholeRoot$genepos$attributes = as.character(lapply(as.character(WholeRoot$genepos$attributes), set_attri)) | |
13 # | |
14 # write.table(WholeRoot$genepos, file = "input_TAIR10_annotation.gtf", row.names = FALSE, col.names = FALSE, sep = "\t", quote = FALSE) | |
15 # write.table(WholeRoot$smat, file = "input_read_count_smt.tsv", col.names = FALSE, sep = "\t", quote = FALSE) | |
16 # write.table(WholeRoot$asmat, file = "input_read_count_asmt.tsv", col.names = FALSE, sep = "\t", quote = FALSE) | |
17 # | |
18 # write.table(WholeRoot$pospairs, file = "input_positive_pair.tsv", row.names = FALSE, col.names = FALSE, sep = "\t", quote = FALSE) | |
19 | |
20 genepos = read.delim("input_TAIR10_annotation.gtf", header=FALSE, comment.char="#") | |
21 colnames(genepos) = c("seqname", "source", "feature", "start", "end", "score", "strand", "frame", "attributes") | |
22 genepos = subset(genepos, feature=="gene") | |
23 | |
24 get_id = function(attri){ | |
25 gene_info = strsplit(attri, ";")[[1]][1] | |
26 gene_id = strsplit(gene_info, " ")[[1]][2] | |
27 gene_id = gsub("\"", "", gene_id) | |
28 return(gene_id) | |
29 } | |
30 | |
31 genepos$attributes = as.character(lapply(as.character(genepos$attributes), get_id)) | |
32 | |
33 pospairs = read.table("input_positive_pair.tsv", sep = "\t", as.is = TRUE) | |
34 | |
35 smat = as.matrix(read.table("input_read_count_smt.tsv", sep = "\t", row.names = 1)) | |
36 | |
37 asmat = as.matrix(read.table("input_read_count_asmt.tsv", sep = "\t", row.names = 1)) | |
38 | |
39 WRscore = getNASTIscore(smat, asmat) | |
40 | |
41 negpairs = getnegativepairs(genepos) | |
42 | |
43 WRpred = NASTIpredict(smat,asmat, pospairs, negpairs) | |
44 | |
45 WRpred_rocr = prediction(WRpred$predictions,WRpred$labels) | |
46 | |
47 thr = defineFDR(WRpred_rocr,0.05) | |
48 | |
49 WR_names = FindNATs(WRscore, thr, pospairs, genepos) | |
50 | |
51 write.table(WR_names$newpairs, file = "output_newpairs.tsv", row.names = FALSE, col.names = FALSE, sep = "\t", quote = FALSE) | |
52 | |
53 write.table(WR_names$neworphan, file = "output_neworphan.tsv", row.names = FALSE, col.names = FALSE, sep = "\t", quote = FALSE) |