annotate scpipe.R @ 0:57baf87c7fcd 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:22 -0400
parents
children 9f8ce2980849
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
57baf87c7fcd 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 ) } )
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
2
57baf87c7fcd 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.
57baf87c7fcd 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")
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
5
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
6 suppressPackageStartupMessages({
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
7 library(scPipe)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
8 library(SingleCellExperiment)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
9 library(optparse)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
10 library(readr)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
11 library(ggplot2)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
12 library(plotly)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
13 library(DT)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
14 library(scater)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
15 library(scran)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
16 library(scales)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
17 library(Rtsne)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
18 })
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
19
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
20 option_list <- list(
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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"),
57baf87c7fcd 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")
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
46 )
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
47
57baf87c7fcd 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)
57baf87c7fcd 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)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
50
57baf87c7fcd 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
57baf87c7fcd 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
57baf87c7fcd 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
57baf87c7fcd 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
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
55 read_structure = list(
57baf87c7fcd 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
57baf87c7fcd 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
57baf87c7fcd 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
57baf87c7fcd 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
57baf87c7fcd 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
57baf87c7fcd 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
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
62 )
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
63
57baf87c7fcd 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) {
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
65 has_umi = FALSE
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
66 } else {
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
67 has_umi = TRUE
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
68 }
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
69
57baf87c7fcd 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)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
71
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
72 # Outputs
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
73 out_dir = "."
57baf87c7fcd 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"))
57baf87c7fcd 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")
57baf87c7fcd 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")
57baf87c7fcd 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")
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
78
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
79
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
80 print("Trimming barcodes")
57baf87c7fcd 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,
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
82 fq_R1,
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
83 fq_R2,
57baf87c7fcd 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,
57baf87c7fcd 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)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
86
57baf87c7fcd 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")
57baf87c7fcd 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)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
89
57baf87c7fcd 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")
57baf87c7fcd 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,
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
92 readfile1=combined_fastq,
57baf87c7fcd 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,
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
94 nthreads=args$nthreads)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
95
57baf87c7fcd 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)) {
57baf87c7fcd 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
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
98 } else {
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
99 print("Detecting barcodes")
57baf87c7fcd 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
57baf87c7fcd 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"
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
102 sc_detect_bc(
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
103 infq=combined_fastq,
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
104 outcsv=barcode_anno,
57baf87c7fcd 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,
57baf87c7fcd 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,
57baf87c7fcd 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,
57baf87c7fcd 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
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
109 )
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
110 }
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
111
57baf87c7fcd 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")
57baf87c7fcd 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)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
114
57baf87c7fcd 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")
57baf87c7fcd 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)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
117
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
118 print("Counting genes")
57baf87c7fcd 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)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
120
57baf87c7fcd 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")
57baf87c7fcd 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)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
123
57baf87c7fcd 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)) {
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
125 print("Creating report")
57baf87c7fcd 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,
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
127 outdir=out_dir,
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
128 r1=fq_R1,
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
129 r2=fq_R2,
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
130 outfq=combined_fastq,
57baf87c7fcd 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,
57baf87c7fcd 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,
57baf87c7fcd 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,
57baf87c7fcd 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,
57baf87c7fcd 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,
57baf87c7fcd 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,
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
137 stnd=args$stnd,
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
138 fix_chr=FALSE,
57baf87c7fcd 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,
57baf87c7fcd 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,
57baf87c7fcd 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,
57baf87c7fcd 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)
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
143 }
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
144
57baf87c7fcd 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) ) {
57baf87c7fcd 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"))
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
147 }
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
148
57baf87c7fcd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scpipe commit 8908da9cdd112ae0943dbf1eccb221e84cd99ca7
iuc
parents:
diff changeset
149 sessionInfo()