annotate rmarkdown_feature_counts.Rmd @ 3:40704501d8c4 draft default tip

update
author mingchen0919
date Fri, 29 Dec 2017 22:17:46 -0500
parents a7f7e8a58a82
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
1 ---
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
2 title: 'Feature Counts'
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
3 output:
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
4 html_document:
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
5 number_sections: true
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
6 toc: true
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
7 theme: cosmo
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
8 highlight: tango
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
9 ---
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
10
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
11 ```{r setup, include=FALSE, warning=FALSE, message=FALSE}
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
12 knitr::opts_chunk$set(
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
13 echo = opt$echo,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
14 error = TRUE
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
15 )
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
16 ```
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
17
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
18
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
19 # User input
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
20
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
21 ```{r 'user input'}
1
mingchen0919
parents: 0
diff changeset
22 user_input = data.frame(name = names(opt)[-1],
mingchen0919
parents: 0
diff changeset
23 value = unlist(opt))
mingchen0919
parents: 0
diff changeset
24 datatable(user_input, rownames = FALSE)
0
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
25 ```
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
26
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
27 # Calculate feature counts
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
28
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
29 ```{r 'ste[ 2'}
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
30 res = featureCounts(
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
31 files = strsplit(opt$input_bam_paths, ',')[[1]],
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
32 # annotation
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
33 annot.inbuilt=opt$annot_inbuilt,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
34 annot.ext=opt$annot_ext,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
35 isGTFAnnotationFile=opt$isGTFAnnotationFile,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
36 GTF.featureType=opt$gtf_feature_type,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
37 GTF.attrType=opt$gtf_attr_type,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
38 chrAliases=opt$chr_aliases,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
39
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
40 # level of summarization
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
41 useMetaFeatures=opt$use_meta_features,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
42
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
43 # overlap between reads and features
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
44 allowMultiOverlap=opt$allow_multi_overlap,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
45 minOverlap=opt$min_overlap,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
46 largestOverlap=opt$largest_overlap,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
47 readExtension5=opt$read_extension_5,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
48 readExtension3=opt$read_extension_3,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
49 read2pos=opt$read_2_pos,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
50
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
51 # multi-mapping reads
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
52 countMultiMappingReads=opt$count_multi_mapping_reads,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
53 fraction=opt$fraction,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
54
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
55 # read filtering
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
56 minMQS=opt$min_mqs,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
57 splitOnly=opt$split_only,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
58 nonSplitOnly=opt$non_split_only,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
59 primaryOnly=opt$primary_only,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
60 ignoreDup=opt$ignore_dup,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
61
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
62 # strandness
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
63 strandSpecific=opt$strand_specific,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
64
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
65 # exon-exon junctions
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
66 juncCounts=opt$junc_counts,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
67 genome=opt$genome,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
68
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
69 # parameters specific to paired end reads
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
70 isPairedEnd=opt$is_paired_end,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
71 requireBothEndsMapped=opt$require_both_ends_mapped,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
72 checkFragLength=opt$check_frag_length,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
73 minFragLength=opt$min_frag_length,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
74 maxFragLength=opt$max_frag_length,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
75 countChimericFragments=opt$count_chimeric_fragments,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
76 autosort=opt$auto_sort,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
77
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
78 # miscellaneous
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
79 nthreads=opt$n_threads,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
80 maxMOp=opt$max_mop,
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
81 reportReads=opt$report_reads
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
82 )
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
83 ```
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
84
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
85 # Write counts into CSV file
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
86
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
87 ```{r}
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
88 colnames(res$counts) = strsplit(opt$input_bam_names, ',')[[1]]
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
89 # write count into csv file
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
90 write.table(res$counts, file = 'feature_counts.txt')
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
91 ```
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
92
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
93 Display the first 100 rows.
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
94
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
95 ```{r}
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
96 datatable(head(res$counts, 100))
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
97 ```
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
98
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
99 # Save results into RData file
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
100
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
101 ```{r}
1
mingchen0919
parents: 0
diff changeset
102 save(opt, res, file = 'feature_counts.RData')
0
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
103 str(res)
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
104 ```
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
105
5af86972b408 planemo upload
mingchen0919
parents:
diff changeset
106