Package: psite
PSitePSiteis a python package that predicts P-site offsets for footprints generated in ribosome profiling using a Gradient Boosting Trees (GBT) model trained with footprints around both annotated start and stop codons.PSitecan report estimated P-site offsets in two manners:append aPStag to each original alignment inSAMorBAMformat, without any other modifications;output a newBAMfile of the alignments of P-site locations only;To demonstrate the usage of thePStag,PSitealso has acoveragemodule that performs genome-wide calculation of P-site coverage of ribosome footprints at nucleotide resolution.Dependencynumpy>= 1.21.21.3.4 <=pandas< 2.0.0biopython>= 1.79scikit-learn>= 1.1.1pysam>= 0.17.0pyBigWig>= 0.3.18click>= 8.1.2seaborn>= 0.11.0Install and uninstallTo installPSite, runpipinstallpsiteAlternatively, download the packagetarballfrom the release page and runpip install psite-version-py3-none-any.whlTo uninstall it, simply runpip uninstall psiteBuild distributions from sourceRun the following command in the source directorypython3-mbuildUsagePSiteis designed to be used from the command line on Unix-like operating systems such as Linux or macOS.$psite-h
Usage:psite[OPTIONS]COMMAND[ARGS]...maininterface

Options:-h,--helpShowthismessageandexit.

Commands:coveragecalculatethecoverageforplusstrandandminusstrand...pbamgeneratebamwithonlyP-siteregionspredictloadpre-trainedmodelandpredictP-siteoffsetssetpsetglobalfixedP-siteoffsettagtraintrainamodelforP-siteoffsetpredictiontrainThe core module that trains the GBT model for P-site offset prediction. It requires transcriptome alignments (PATH_BAM) and the corresponding sequences of all transcripts (PATH_REF). The required bam can be generated by mapping footprints to the reference genome usingSTARand output transcriptome alignments with parameter--quantMode TranscriptomeSAM. The trained model is saved inpickleformat for later use.$psitetrain-h
Usage:psitetrain[OPTIONS]PATH_REFPATH_BAMOUTPUT_PREFIXPATH_TXINFOtrainamodelforP-siteoffsetpredictionpath_ref:referencetranscriptome(fasta)matchingthebampath_bam:alignmentsofRPFstoreferencetranscriptomeoutput_prefix:outputprefixoffittedmodelsandlogspath_txinfo:transcriptomeannotation

Options:-t,--type_rep[longest|principal|kallisto|salmon]typeofrepresentativetranscripts[default:longest]-e,--path_expTEXTpathoftranscriptexpressionquantresults-i,--ignore_txversionignoretranscriptversionin".\d+"format[default:False]-n,--ntsINTEGERflankingnucleotidestoconsiderateachside[default:3]-f,--fracFLOATfractionofalignmentsfortraining(forlargedatasets)[default:1.0]--offset_minINTEGERlowerboundofdistancebetweenRPF5pandstartcodon[default:10]--offset_maxINTEGERupperboundofdistancebetweenRPF5pandstartcodon[default:14]-d,--max_depthINTEGERmaxdepthoftrees[default:3]-m,--min_samples_splitINTEGERminnumberofalignmentsrequiredtosplitaninternalnode[default:6]-k,--keepwhethertokeepintermediateresults[default:False]-h,--helpShowthismessageandexit.[default:False]predictThis module predicts P-site for each alignment using a pre-trained model and append aPStag (for "P-site") to the original alignment. The input can be either genomic alignments or transcriptomic alignments.$psitepredict-h
Usage:psitepredict[OPTIONS]PATH_REFPATH_BAMPATH_MODELPATH_OUTloadpre-trainedmodelandpredictP-siteoffsetspath_ref:referencetranscriptome(fasta)matchingthebampath_bam:alignmentsofRPFstoreferencetranscriptomepath_model:pathtosavethefittedmodelpath_out:outputpathofbamwithPS(forP-site)tag

Options:-i,--ignore_txversionignoretranscriptversionin".\d+"format[default:False]-l,--rlen_minINTEGERlowerboundformappedreadlength-u,--rlen_maxINTEGERupperboundformappedreadlength-c,--chunk_sizeINTEGERchunksizeforpredictionbatch[default:100000]-h,--helpShowthismessageandexit.[default:False]pbamThis module predicts P-site for each alignment and keeps only the first nucleotide after excluding the P-site offset. Thus, each alignment in the output contains a single site. The input can be either genomic alignments or transcriptomic alignments.$psitepbam-h
Usage:psitepbam[OPTIONS]PATH_REFPATH_BAMPATH_MODELPATH_OUTgeneratebamwithonlyP-siteregionspath_ref:referencetranscriptome(fasta)matchingthebampath_bam:alignmentsofRPFstoreferencetranscriptomepath_model:pathtosavethefittedmodelpath_out:outputpathofbamwithP-siteregionsonly

Options:-f,--out_format[bam|sam]P-sitealignmentoutputformat[default:bam]-i,--ignore_txversionignoretranscriptversionin".\d+"format[default:False]-l,--rlen_minINTEGERlowerboundformappedreadlength-u,--rlen_maxINTEGERupperboundformappedreadlength-c,--chunk_sizeINTEGERchunksizeforpredictionbatch[default:100000]-h,--helpShowthismessageandexit.[default:False]coverageThis module calculates the genome or transcriptome-wide coverage of RPF P-sites using thePStag generatd bypredictmodule.$psitecoverage-h
Usage:psitecoverage[OPTIONS]PATH_BAMPREFIXcalculatethecoverageforplusstrandandminusstrandseparatelypath_bam:sortedalignmentbamfilewiththePStag(forP-siteoffset)prefix:outputprefixofP-sitecoveragetracksinbigWigformat

Options:-l,--rlen_minINTEGERlowerboundforRPFmappedlength[default:25]-u,--rlen_maxINTEGERupperboundformappedreadlength[default:40]-q,--mapq_minINTEGERminimummappingquality[default:10]-i,--ignore_suppwhethertoignoresupplementaryalignments[default:False]-h,--helpShowthismessageandexit.[default:False]setpThis module sets a global fixed value for the "PS" tag.$psitesetp-h
Usage:psitesetp[OPTIONS]PATH_BAMPATH_OUTsetglobalfixedP-siteoffsettagpath_bam:alignmentsofRPFstoreferencetranscriptomepath_out:outputpathofbamwithPS(forP-site)tag

Options:-l,--rlen_minINTEGERlowerboundformappedreadlength[default:27]-u,--rlen_maxINTEGERupperboundformappedreadlength[default:35]-n,--nucleotidesINTEGERfixedglobaloffsetvalue[default:12]-h,--helpShowthismessageandexit.An example workflow to use PSitePrepare input filesAfter trimming adapters and optionally removing reads derived from rRNAs or tRNAs, map ribosomal footprints to the reference genome with STAR:STAR--runThreadN16--outFilterTypeBySJout--outFilterMismatchNmax2--genomeDirgenome_index--readFilesInsample_RPF.fq.gz--outFileNamePrefixsample_RPF--readFilesCommandzcat--outSAMtypeBAMSortedByCoordinate--quantModeTranscriptomeSAM--outFilterMultimapNmax1--outFilterMatchNmin16--alignEndsTypeEndToEnd--outSAMattributesNHHIASnMNMMDThe parameter--quantMode TranscriptomeSAMwill instruct STAR to translate the genomic alignments into transcript alignments, which will be used to train the GBT model. Since many uniquely mapped reads in genomic alignments will become multi-mapping reads in transcriptome alignment due to the presence of alternative transcript isoforms,--outFilterMultimapNmax 1parameter is included to exlude only multi-mapping reads in genomic alignments.PSite needs to know the position of annotated start codons and stop codons of all protein-coding transcripts, which can be obtained with the helper scripts located in thescriptsdirectory:Rscript--vanillascripts/extract_txinfo_ensembl.Rgene_annotations.gtftxinfo.tsvOnly a represent isoform is used in the analysis for a gene with multiple transcript isoforms. By default, PSite uses the longest transcript. However, a more reasonable choice is the most abundant isoform. Therefore, if the information of transcript abundance as calculated bykallistoorsalmonis provided, PSite can automatically determine the most abundant transcript isoform for later use:salmonquant-p4--seqBias--gcBias--posBias-lA-isalmon_index-rsample_RNA.fq.gz-osalmon_resultsRun PSiteThe first step is to train a GBT model withtrainmodule with the transcriptome bam. Then, the fitted model will be saved inpickleformat.psitetrain-i-tsalmon-esalmon_results/quant.sf\all_transcripts.fasample_RPF.Aligned.toTranscriptome.out.bamoutput_prefixtxinfo.tsvModel training is slow for large datasets.-fparameter can be used to select only a subset of alignments for training. This can significantly improve speed and reduce memory usage while maintaining similar accuracy.Once the model is successfully trained, it can be used to predict P-site offsets for ribosome footprints that are mapped to the reference genome or reference transcriptomes. It should be noted that if you use genome bam for prediction, genomic fasta should be used as input, and vice versa.# with transcriptomic bampsitepredict-iall_transcripts.fasample_RPF.Aligned.toTranscriptome.out.bamoutput_prefix.gbt.picklesample_RPF.transcriptome.tag.bam# with genomic bampsitepredict-igenome.fasample_RPF.Aligned.sortedByCoord.out.bamoutput_prefix.gbt.picklesample_RPF.genome.tag.bamexample output:r1	16	2L	10716	255	29M	*	0	0	TACAATTTATTAAATGGGGACGGACCAAT	IIIIIIIIIIIIIIIIIIIIIHIIDDDDD	NH:i:1	HI:i:1	AS:i:28	nM:i:0	NM:i:0	MD:Z:29	jM:B:c,-1	jI:B:i,-1	PS:i:10
r2	16	2L	10836	255	33M	*	0	0	TGTCAACTTTTATCCTTTGTACCTTTCTACAAA	IIIIIIIIIIIIIIIIIIIIIIIIIIIIDDDDD	NH:i:1	HI:i:1	AS:i:32	nM:i:0	NM:i:0	MD:Z:33	jM:B:c,-1	jI:B:i,-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M:i:0	NM:i:0	MD:Z:29	jM:B:c,-1	jI:B:i,-1	PS:i:10
r10	16	2L	11140	255	32M	*	0	0	TCAGGACTAGTACTCGTTTGCGTCGTATTTCT	FCCHHCHIHIHHE0HHHDECHIH?IHG@0@D@	NH:i:1	HI:i:1	AS:i:31	nM:i:0	NM:i:0	MD:Z:32	jM:B:c,-1	jI:B:i,-1	PS:i:13It is also possible to output alignments with P-site locations only, which can be used for downstream applications such as translated ORF prediction withRibORF.psitepbam-fsamgenome.fasample_RPF.Aligned.sortedByCoord.out.bamoutput_prefix.gbt.picklesample_RPF.genome.psite.samHere are a few lines from an example output:r1      16      1       531180  255     1M      *       0       0       G       J       NH:i:1  HI:i:1  AS:i:30 nM:i:0  NM:i:0  MD:Z:31
r2      16      1       531180  255     1M      *       0       0       G       J       NH:i:1  HI:i:1  AS:i:30 nM:i:0  NM:i:0  MD:Z:31
r3      0       1       629921  255     1M      *       0       0       A       J       NH:i:1  HI:i:1  AS:i:31 nM:i:1  NM:i:1  MD:Z:0C33
r4      0       1       629921  255     1M      *       0       0       A       J       NH:i:1  HI:i:1  AS:i:31 nM:i:1  NM:i:1  MD:Z:0C33
r5      0       1       629922  255     1M      *       0       0       T       J       NH:i:1  HI:i:1  AS:i:32 nM:i:0  NM:i:0  MD:Z:33
r6      0       1       629922  255     1M      *       0       0       T       J       NH:i:1  HI:i:1  AS:i:29 nM:i:1  NM:i:1  MD:Z:0C31
r7      0       1       629922  255     1M      *       0       0       T       J       NH:i:1  HI:i:1  AS:i:29 nM:i:1  NM:i:1  MD:Z:0C31
r8      0       1       629922  255     1M      *       0       0       T       J       NH:i:1  HI:i:1  AS:i:29 nM:i:1  NM:i:1  MD:Z:0C31
r9      0       1       629922  255     1M      *       0       0       T       J       NH:i:1  HI:i:1  AS:i:32 nM:i:0  NM:i:0  MD:Z:33
r10     0       1       629922  255     1M      *       0       0       T       J       NH:i:1  HI:i:1  AS:i:30 nM:i:1  NM:i:1  MD:Z:0C32PSite also has a module for fast calculation of genome or transcriptome P-site coverage of ribosome footprints. The alignments should be sorted by coordinates before coverage calculation.# sort bamsamtoolssort-@8-Obam-osample_RPF.genome.tag.sorted.bamsample_RPF.genome.tag.bam# calculate coveragepsitecoveragesample_RPF.genome.tag.sorted.bamsample_RPF.psite_covNEW: a complete example of how to run PSite and use PSite output for downstream analyses is available from therepository associated with PSite manuscript.Other informationPlease use theissuespanel for questions related toPSite, bug reports, or feature requests. If you usepsitein your work, you can cite it as follows:Chang, Y., Lei, T., Zhang, H., 2023. PSite: inference of read-specific P-site offsets for ribosomal footprints. bioRxiv, 2023.2006.2027.546788.https://doi.org/10.1101/2023.06.27.546788.