Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
initial commit
  • Loading branch information
MPIBR-tushevg committed Oct 19, 2018
1 parent d35f5d5 commit 463145c
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
.DS_store
24 changes: 24 additions & 0 deletions README.md
@@ -1,2 +1,26 @@
# CellrangerPipeline
batch run for cellranger count

```
perl batchCellrangerCounter.pl --help
version 1.0, October 2018
usage: batchCellrangerCounter.pl
-f|--fastq
path to FastQ files (required)
-o|--output-dir
path to output directory (required)
-g|--genome
path to genome index (required)
-p|--opts
additional Cellranger Count parameters
-h|--help
print help message
-v|--version
print current version
```

example:

```
perl batchCellrangerCounter.pl --fastq /path/to/fastq/ --output-dir /path/to/projec/cellranger_count_out/ --genome /path/to/genome/alien/cellranger/ --opts "--chemistry SC3Pv2 --localcores=32 --force-cells=7000"
```
142 changes: 142 additions & 0 deletions batchCellrangerCounter.pl
@@ -0,0 +1,142 @@
#!/usr/bin/perl

use warnings;
use strict;
use Getopt::Long();

sub usage($);
sub version($);

sub createBatchJob($);
sub runCellranger($$$$);

MAIN:
{
# define inputs
my $version_tag = "version 1.0, October 2018";
my $version;
my $help;
my $path_fastq;
my $path_genome_index;
my $path_output;
my $opts_cellranger;

# set-up paramters
Getopt::Long::GetOptions(
"f|fastq=s" => \$path_fastq,
"o|output-dir=s" => \$path_output,
"g|genome=s" => \$path_genome_index,
"p|opts=s" => \$opts_cellranger,
"h|help" => \$help,
"v|version" => \$version
) or usage("Error::invalid command line options");

# parse inputs
version($version_tag) if($version);
usage($version_tag) if($help);
usage("Error::path to FastQ files is required") unless defined($path_fastq);
usage("Error::path to output location is required") unless defined($path_output);
usage("Error::path to genome index is required") unless defined($path_genome_index);

# create batch job
my $batch_job = createBatchJob($path_fastq);

# run cellranger count
runCellranger($batch_job, $path_output, $path_genome_index, $opts_cellranger);

}


sub runCellranger($$$$)
{
my $batch_job = $_[0];
my $path_output = $_[1];
my $path_genome_index = $_[2];
my $opts_cellranger = $_[3];

foreach my $id (sort keys %{$batch_job})
{
my $command = "cellranger count" .
" --id=" . $id .
" --fastqs=" . $batch_job->{$id} .
" --transcriptome=" . $path_genome_index .
" --sample=" . $id;
$command .= " " . $opts_cellranger if (defined($opts_cellranger));

print $command,"\n";
#system($command);

# move result to output folder
if (-d $id)
{
$path_output =~ s/\/$//g;
$command = "mv " . $id . " " . $path_output . '/' . $id;
print $command,"\n";
#system($command);
}
}
}

sub createBatchJob($)
{
my $path_fastq = $_[0];
my %tags = ();

$path_fastq =~ s/\/$//g;

opendir(my $dh, $path_fastq);
while (my $path_tag = readdir $dh)
{

my $path_full = $path_fastq . '/' . $path_tag;
next unless -d $path_full;
next if ($path_tag =~ m/^\./);
$tags{$path_tag} = $path_full;
}
closedir($dh);
return \%tags;
}


sub usage($)
{
my $message = $_[0];
if (defined $message && length($message))
{
$message .= "\n" unless($message =~/\n$/);
}
my $command = $0;
$command =~ s#^.*/##;

print STDERR (
$message,
"usage: $command\n" .
"-f|--fastq\n" .
"\t path to FastQ files (required)\n" .
"-o|--output-dir\n" .
"\t path to output directory (required)\n" .
"-g|--genome\n" .
"\t path to genome index (required)\n" .
"-p|--opts\n" .
"\t additional Cellranger Count parameters\n" .
"-h|--help\n" .
"\t print help message\n" .
"-v|--version\n" .
"\t print current version\n"
);

die("\n");
}

sub version($)
{
my $message = $_[0];
print STDERR (
$message,"\n",
"Scientific Computing Facility\n",
"Max-Planck Institute For Brain Research\n",
"bug reports to:\n",
"\tsciclist\@brain.mpg.de\n"
);
die("\n");
}

0 comments on commit 463145c

Please sign in to comment.