To combine barcodes with 10X we insert transcribable lineage barcodes into cells and then perform 10X on those barcoded cells. 10X will capture the transcribed lineage barcode and attach it's cell barcode to it. Since these reads do not map to the genome, they will be marked as "unmapped" in the possorted_genome_bam.bam file. This wiki walks you through how to use cellranger and this code to extract lineage barcodes and link them to their respective Cell Barcodes (CB).
All this code is run on the pmacs cluster as starcode is very memory intensive. NOTE: If you have already installed this file on the cluster and compiled starcode start at step 9.
- If you don’t already have it I recommend you download cyberduck (https://cyberduck.io) to easily interface with the cluster.
- Once cyberduck is installed, open it, hit open connection, in the top drop-down menu select "SFTP(SSH File Transfer Protocol)", for server type in "mercury.pmacs.upenn.edu", enter your PMACS username and password, and hit connect.
- Download all the files in this GitHub repository by hitting the green "Code" button above on this page, and select "Download ZIP".
- Drag and drop the downloaded file "BarcodeAnalysis_v2_10X-main" into your directory of choice.
- Change the file name from "BarcodeAnalysis-main" to simply "BarcodeAnalysis".
- To set up the virtual environment containing the necessary dependencies, open up terminal and type in
ssh <username>@consign.pmacs.upenn.edureplacing<username>with your PMACS username, and hit enter. Then enter your PMACS password and hit enter. - You should now be in a session on the terminal. Enter
bsub -Is bashto start up an interactive session. - Compile starcode by running:
make -C /path/to/starcode. - We will now make sure we are in the correct python version by entering the command
module load python/3.6.3. If this worked you should be able to enter python--versionand see the outputPython 3.6.3. - Enter cd /path/to/BarcodeAnalysis_v2_10X/. (tip: to get paths of folders I usually right click on them in cyberduck, select "copy URL", and select either choice, and keep everything after ".edu").
- Now set up your virtual environment by entering the line
python -m virtualenv bcEnv. - Next activate your virtual environment by entering
source /path/to/BarcodeAnalysis_v2_10X/bcEnv/bin/activate. - We can now install the necessary packages in this environment by running:
pip install -r /path/to/BarcodeAnalysis_v2_10X/requirements.txt. - Your virtual environment is now ready. If you ever want to leave the virtual environment simply enter
deactivate. Every time you want to active the environment enter:source /path/to/BarcodeAnalysis_v2_10X/bcEnv/bin/activate. - You also need to be able to run CellRanger on the cluster, you can access cellranger by either installing it as described here, or you can use the version of cellranger on the cluster. To use the version on the cluster, simply log in, activate a node by typing in bsub -Is bash, hitting enter, and then entering module load cellranger/5.0.1 (you can see if there are other versions by typing
module avail). If you are downloading cell ranger make sure you add it you your path every time before running a cellranger command by entering this commandexport PATH=/path/to/cellranger-3.1.0:$PATHreplacing with your path to the cellranger folder. If you are using the module on the cluster then just runmodule load cellranger/5.0.1every time before runningcellranger. Note: I downloaded cell ranger so my example files will useexport PATH=/path/to/cellranger-3.1.0:$PATH.
Use cellranger to process your sequencing output. Here's a link to the 10X tutorial.
After running cellranger on the sequencing output, one of your output files will be possorted_genome_bam.bam. This file contains all the reads of your sample. There will be many reads that were not able to map to your genome. A good fraction of these reads should be your lineage barcode reads. To extract these reads, run step1.sh. An example of step1.sh is on the github. There are several things you should check in this script before running it.
- Change the
BSUBcalls to match your desired error/output filenames. - This script calls
samtools. Currently, this script callssamtoolsas a module that is pre-installed in the cluster. - Change the directory to your
/outsdirectory from yourcellrangeroutput. - On line 22, change the output filename as you desire.
- Submit this job to the cluster by inputting
cd path/to/BarcodeAnalysis_v2_10Xandbsub < step1.sh.
Once you've successfully run step1.sh on all your 10X files, move all your .txt files to a new directory. You'll be calling this directory in Step 2.
- Activate the python environment (you should do this everytime you run step2 code). Enter:
source /path/to/BarcodeAnalysis_v2_10X/bcEnv/bin/activate. - Inspect
step2.sh. The only parts of this script that you should change are the#BSUBoptions. You'll notice that this script callsExtractBarcodes_10X.py, and your variables will be called frompaths_and_variables.json. - Inspect
paths_and_variables.json. These are the variables that you'll need to change:scripts_path: Inputpath/to/BarcodeAnalysis_v2_10Xfolder_path: Input the path to the directory that holds all your.txtoutput from Step 1.target1andtarget2: These are the sequences that flank the 20bp lineage barcode. If you are using barcode_v2 from the Shaffer Lab, you should not need to change these sequences.sc_mm: This is the maximum levenschtein distances allowed for two barcode sequences to be considered the same. You may need to empirically determine the optimalsc_mmto get your expected number of unique barcodes. The highest value that the software allows for is 8.
- Submit this job to the cluster by inputting
cd path/to/BarcodeAnalysis_v2_10Xandbsub < step2.sh.
After successfully running step2.sh, you should see the following output files:
step1_output.txt: This is a table that includes the Cell Barcode (CB), 20bp lineage barcode, whether the barcode was found usingtarget1ortarget2, and the*unmapped.txtfile that this CB comes from.sc_input.txt: This is a list of barcodes fromstep1_output.txtthat are fed intostarcodeto cluster barcodes.sc_output.txt: This is the output file fromstarcode.EB_output_modified.txt: Usingsc_output.txt, this script editsstep1_output.txtwith the modified barcodes. This will be the output you use to map each cell to a lineage barcode.combo_counts.txt: This table summarizes the lineage barcodes mapped to each CB. While I use this table as a sanity check, I do not use it for downstream analyses.