annotate scpipe.R @ 0:32e1bfc6b7b2 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
author iuc
date Wed, 15 Aug 2018 13:54:40 -0400
parents
children 5c4bca9dd4a2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
1 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
2
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
3 # we need that to not crash galaxy with an UTF8 error on German LC settings.
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
4 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
5
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
6 suppressPackageStartupMessages({
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
7 library(scPipe)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
8 library(SingleCellExperiment)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
9 library(optparse)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
10 library(readr)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
11 library(ggplot2)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
12 library(plotly)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
13 library(DT)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
14 library(scater)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
15 library(scran)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
16 library(scales)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
17 library(Rtsne)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
18 })
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
19
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
20 option_list <- list(
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
21 make_option(c("-fasta","--fasta"), type="character", help="Genome fasta file"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
22 make_option(c("-exons","--exons"), type="character", help="Exon annotation gff3 file"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
23 make_option(c("-barcodes","--barcodes"), type="character", help="Cell barcodes csv file"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
24 make_option(c("-read1","--read1"), type="character", help="Read 1 fastq.gz"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
25 make_option(c("-read2","--read2"), type="character", help="Read 2 fastq.gz"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
26 make_option(c("-samplename","--samplename"), type="character", help="Name to use for sample"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
27 make_option(c("-bs1","--bs1"), type="integer", help="Barcode start in Read 1"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
28 make_option(c("-bl1","--bl1"), type="integer", help="Barcode length in Read 1"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
29 make_option(c("-bs2","--bs2"), type="integer", help="Barcode start in Read 2"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
30 make_option(c("-bl2","--bl2"), type="integer", help="Barcode length in Read 2"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
31 make_option(c("-us","--us"), type="integer", help="UMI start in Read 2"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
32 make_option(c("-ul","--ul"), type="integer", help="UMI length in Read 2"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
33 make_option(c("-rmlow","--rmlow"), type="logical", help="Remove reads with N in barcode or UMI"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
34 make_option(c("-rmN","--rmN"), type="logical", help="Remove reads with low quality"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
35 make_option(c("-minq","--minq"), type="integer", help="Minimum read quality"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
36 make_option(c("-numbq","--numbq"), type="integer", help="Maximum number of bases below minq"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
37 make_option(c("-stnd","--stnd"), type="logical", help="Perform strand-specific mapping"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
38 make_option(c("-max_mis","--max_mis"), type="integer", help="Maximum mismatch allowed in barcode"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
39 make_option(c("-UMI_cor","--UMI_cor"), type="integer", help="Correct UMI sequence error"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
40 make_option(c("-gene_fl","--gene_fl"), type="logical", help="Remove low abundant genes"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
41 make_option(c("-max_reads","--max_reads"), type="integer", help="Maximum reads processed"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
42 make_option(c("-min_count","--min_count"), type="integer", help="Minimum count to keep"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
43 make_option(c("-report","--report"), type="logical", help="HTML report of plots"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
44 make_option(c("-rdata","--rdata"), type="logical", help="Output RData file"),
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
45 make_option(c("-nthreads","--nthreads"), type="integer", help="Number of threads")
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
46 )
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
47
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
48 parser <- OptionParser(usage = "%prog [options] file", option_list=option_list)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
49 args = parse_args(parser)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
50
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
51 fa_fn = args$fasta
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
52 anno_fn = args$exons
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
53 fq_R1 = args$read1
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
54 fq_R2 = args$read2
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
55 read_structure = list(
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
56 bs1 = args$bs1, # barcode start position in fq_R1, -1 indicates no barcode
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
57 bl1 = args$bl1, # barcode length in fq_R1, 0 since no barcode present
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
58 bs2 = args$bs2, # barcode start position in fq_R2
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
59 bl2 = args$bl2, # barcode length in fq_R2
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
60 us = args$us, # UMI start position in fq_R2
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
61 ul = args$ul # UMI length
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
62 )
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
63
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
64 if (args$us == -1) {
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
65 has_umi = FALSE
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
66 } else {
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
67 has_umi = TRUE
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
68 }
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
69
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
70 filter_settings=list(rmlow=args$rmlow, rmN=args$rmN, minq=args$minq, numbq=args$numbq)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
71
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
72 # Outputs
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
73 out_dir = "."
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
74 fasta_index = file.path(out_dir, paste0(fa_fn, ".fasta_index"))
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
75 combined_fastq = file.path(out_dir, "combined.fastq")
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
76 aligned_bam = file.path(out_dir, "aligned.bam")
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
77 mapped_bam = file.path(out_dir, "aligned.mapped.bam")
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
78
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
79
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
80 print("Trimming barcodes")
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
81 sc_trim_barcode(combined_fastq,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
82 fq_R1,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
83 fq_R2,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
84 read_structure=read_structure,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
85 filter_settings=filter_settings)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
86
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
87 print("Building genome index")
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
88 Rsubread::buildindex(basename=fasta_index, reference=fa_fn)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
89
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
90 print("Aligning reads to genome")
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
91 Rsubread::align(index=fasta_index,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
92 readfile1=combined_fastq,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
93 output_file=aligned_bam,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
94 nthreads=args$nthreads)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
95
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
96 if (!is.null(args$barcodes)) {
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
97 barcode_anno=args$barcodes
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
98 } else {
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
99 print("Detecting barcodes")
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
100 # detect 10X barcodes and generate sample_index.csv file
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
101 barcode_anno = "sample_index.csv"
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
102 sc_detect_bc(
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
103 infq=combined_fastq,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
104 outcsv=barcode_anno,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
105 bc_len=read_structure$bl2,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
106 max_reads=args$max_reads,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
107 min_count=args$min_count,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
108 max_mismatch=args$max_mis
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
109 )
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
110 }
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
111
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
112 print("Assigning reads to exons")
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
113 sc_exon_mapping(aligned_bam, mapped_bam, anno_fn, bc_len=read_structure$bl2, UMI_len=read_structure$ul, stnd=args$stnd)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
114
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
115 print("De-multiplexing data")
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
116 sc_demultiplex(mapped_bam, out_dir, barcode_anno, has_UMI=has_umi)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
117
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
118 print("Counting genes")
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
119 sc_gene_counting(out_dir, barcode_anno, UMI_cor=args$UMI_cor, gene_fl=args$gene_fl)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
120
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
121 print("Creating SingleCellExperiment object")
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
122 sce <- create_sce_by_dir(out_dir)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
123
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
124 if (!is.null(args$report)) {
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
125 print("Creating report")
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
126 create_report(sample_name=args$samplename,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
127 outdir=out_dir,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
128 r1=fq_R1,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
129 r2=fq_R2,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
130 outfq=combined_fastq,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
131 read_structure=read_structure,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
132 filter_settings=filter_settings,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
133 align_bam=aligned_bam,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
134 genome_index=fasta_index,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
135 map_bam=mapped_bam,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
136 exon_anno=anno_fn,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
137 stnd=args$stnd,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
138 fix_chr=FALSE,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
139 barcode_anno=barcode_anno,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
140 max_mis=args$max_mis,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
141 UMI_cor=args$UMI_cor,
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
142 gene_fl=args$gene_fl)
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
143 }
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
144
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
145 if (!is.null(args$rdata) ) {
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
146 save(sce, file = file.path(out_dir,"scPipe_analysis.RData"))
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
147 }
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
148
32e1bfc6b7b2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
149 sessionInfo()