Package: rs3
Rule Set 3Python package to predict the activity of CRISPR sgRNA sequences using Rule Set 3InstallYou can install the latest release of rs3 from pypi usingpip install rs3For mac users you may also have to brew install the OpenMP librarybrew install libompor install lightgbm without Openmppip install lightgbm --install-option=--nompSee theLightGBM documentationfor more informationDocumentationYou can see the complete documentation for Rule Set 3here.Quick StartSequence based modelTo calculate Rule Set 3 (sequence) scores, import the predict_seq function from the seq module.from rs3.seq import predict_seqYou can store the 30mer context sequences you want to predict as a list.context_seqs = ['GACGAAAGCGACAACGCGTTCATCCGGGCA', 'AGAAAACACTAGCATCCCCACCCGCGGACT']You can specify theHsu2013orChen2013as the tracrRNA to score with.
We generally find any tracrRNA that does not have a T in the fifth position is better predicted with the Chen2013 input.predict_seq(context_seqs, sequence_tracr='Hsu2013')Calculating sequence-based features


100%|██████████| 2/2 [00:00<00:00, 15.04it/s]





array([-0.90030944,  1.11451622])Target based modelTo get target scores, which use features at the endogenous target site to make predictions,
you must build or load feature matrices for the amino acid sequences, conservation scores, and protein domains.As an example, we'll calculate target scores for 250 sgRNAs in the GeckoV2 library.import pandas as pd
from rs3.predicttarg import predict_target
from rs3.targetfeat import (add_target_columns,
                            get_aa_subseq_df,
                            get_protein_domain_features,
                            get_conservation_features)design_df = pd.read_table('test_data/sgrna-designs.txt')
design_df.head()<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>InputQuotaTarget TaxonTarget Gene IDTarget Gene SymbolTarget TranscriptTarget Reference CoordsTarget AliasCRISPR MechanismTarget Domain...On-Target Rank WeightOff-Target Rank WeightCombined RankPreselected AsMatching Active Arrayed OligosMatching Arrayed ConstructsPools Containing Matching ConstructPick OrderPicking RoundPicking Notes0PSMB729606ENSG00000136930PSMB7ENST00000259457.8NaNNaNCRISPRkoCDS...1.01.07GCAGATACAAGAGCAACTGANaNBRDN0004619103NaN10Preselected1PSMB729606ENSG00000136930PSMB7ENST00000259457.8NaNNaNCRISPRkoCDS...1.01.048AAAACTGGCACGACCATCGCNaNNaNNaN20Preselected2PRC129606ENSG00000198901PRC1ENST00000394249.8NaNNaNCRISPRkoCDS...1.01.07AAAAGATTTGCGCACCCAAGNaNNaNNaN10Preselected3PRC129606ENSG00000198901PRC1ENST00000394249.8NaNNaNCRISPRkoCDS...1.01.08CTTTGACCCAGACATAATGGNaNNaNNaN20Preselected4TOP129606ENSG00000198900TOP1ENST00000361337.3NaNNaNCRISPRkoCDS...1.01.01NaNNaNBRDN0001486452NaN21NaN5 rows × 60 columnsThroughout the analysis we will be using a core set of ID columns to merge the feature matrices. These ID columns
should uniquely identify an sgRNA and its target site.id_cols = ['sgRNA Context Sequence', 'Target Cut Length', 'Target Transcript', 'Orientation']Amino acid sequence inputTo calculate the amino acid sequence matrix, you must first load the complete sequence from ensembl using thebuild_transcript_aa_seq_df. See the documentation for thepredicttargmodule for an example of how to
use this function.In this example we will use amino acid sequences that have been precalculated using thewrite_transcript_datafunction in thetargetdatamodule. Check out the documentation for this module for more information on
how to use this function.We use pyarrow to read the written transcript data.
The stored transcripts are indexed by their Ensembl ID without the version number identifier.
To get this shortened version of the Ensembl ID use theadd_target_columnsfunction from thetargetfeatmodule.
This function adds the 'Transcript Base' column as well as a column indicating the amino acid index ('AA Index')
of the cut site. The 'AA Index' column will be used for merging with the amino acid translations.design_targ_df = add_target_columns(design_df)
design_targ_df.head()<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>InputQuotaTarget TaxonTarget Gene IDTarget Gene SymbolTarget TranscriptTarget Reference CoordsTarget AliasCRISPR MechanismTarget Domain...Combined RankPreselected AsMatching Active Arrayed OligosMatching Arrayed ConstructsPools Containing Matching ConstructPick OrderPicking RoundPicking NotesAA IndexTranscript Base0PSMB729606ENSG00000136930PSMB7ENST00000259457.8NaNNaNCRISPRkoCDS...7GCAGATACAAGAGCAACTGANaNBRDN0004619103NaN10Preselected64ENST000002594571PSMB729606ENSG00000136930PSMB7ENST00000259457.8NaNNaNCRISPRkoCDS...48AAAACTGGCACGACCATCGCNaNNaNNaN20Preselected46ENST000002594572PRC129606ENSG00000198901PRC1ENST00000394249.8NaNNaNCRISPRkoCDS...7AAAAGATTTGCGCACCCAAGNaNNaNNaN10Preselected106ENST000003942493PRC129606ENSG00000198901PRC1ENST00000394249.8NaNNaNCRISPRkoCDS...8CTTTGACCCAGACATAATGGNaNNaNNaN20Preselected263ENST000003942494TOP129606ENSG00000198900TOP1ENST00000361337.3NaNNaNCRISPRkoCDS...1NaNNaNBRDN0001486452NaN21NaN140ENST000003613375 rows × 62 columnstranscript_bases = design_targ_df['Transcript Base'].unique()
transcript_bases[0:5]array(['ENST00000259457', 'ENST00000394249', 'ENST00000361337',
       'ENST00000368328', 'ENST00000610426'], dtype=object)aa_seq_df = pd.read_parquet('test_data/target_data/aa_seqs.pq', engine='pyarrow',
                            filters=[[('Transcript Base', 'in', transcript_bases)]])
aa_seq_df.head()<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>Target TranscriptTarget Total LengthTranscript BaseversionseqmoleculedescidAA len0ENST00000259457.8834ENST000002594573MAAVSVYAPPVGGFSFDNCRRNAVLEADFAKRGYKLPKVRKTGTTI...proteinNoneENSP000002594572771ENST00000394249.81863ENST000003942493MRRSEVLAEESIVCLQKALNHLREIWELIGIPEDQRLQRTEVVKKH...proteinNoneENSP000003777936202ENST00000361337.32298ENST000003613372MSGDHLHNDSQIEADFRLNDSHKHKDKHKDREHRHKEHKKEKDREK...proteinNoneENSP000003545227653ENST00000368328.5267ENST000003683284MALSTIVSQRKQIKRKAPRGFLKRVFKRKKPQLRLEKSGDLLVHLN...proteinNoneENSP00000357311884ENST00000610426.5783ENST000006104261MPQNEYIELHRKRYGYRLDYHEKKRKKESREAHERSKKAKKMIGLK...proteinNoneENSP00000483484260From the complete transcript translations, we extract an amino acid subsequence as input to our model. The subsequence
is centered around the amino acid encoded by the nucleotide preceding the cut site in the direction of transcription.
This is the nucleotide that corresponds to the 'Target Cut Length' in a CRISPick design file.
We take 16 amino acids on either side of the cut site for a total sequence length of 33.Theget_aa_subseq_dffrom thetargetfeatmodule will calculate these subsequences
from the complete amino acid sequences.aa_subseq_df = get_aa_subseq_df(sg_designs=design_targ_df, aa_seq_df=aa_seq_df, width=16,
                                id_cols=id_cols)
aa_subseq_df.head()<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>Target TranscriptTarget Total LengthTranscript BaseversionseqmoleculedescidAA lenTarget Cut LengthOrientationsgRNA Context SequenceAA Indexextended_seqAA 0-IndexedAA 0-Indexed paddedseq_startseq_endAA Subsequence0ENST00000259457.8834ENST000002594573MAAVSVYAPPVGGFSFDNCRRNAVLEADFAKRGYKLPKVRKTGTTI...proteinNoneENSP00000259457277191senseTGGAGCAGATACAAGAGCAACTGAAGGGAT64-----------------MAAVSVYAPPVGGFSFDNCRRNAVLEADF...63806496GVVYKDGIVLGADTRATEGMVVADKNCSKIHFI1ENST00000259457.8834ENST000002594573MAAVSVYAPPVGGFSFDNCRRNAVLEADFAKRGYKLPKVRKTGTTI...proteinNoneENSP00000259457277137senseCCGGAAAACTGGCACGACCATCGCTGGGGT46-----------------MAAVSVYAPPVGGFSFDNCRRNAVLEADF...45624678AKRGYKLPKVRKTGTTIAGVVYKDGIVLGADTR2ENST00000394249.81863ENST000003942493MRRSEVLAEESIVCLQKALNHLREIWELIGIPEDQRLQRTEVVKKH...proteinNoneENSP00000377793620316senseTAGAAAAAGATTTGCGCACCCAAGTGGAAT106-----------------MRRSEVLAEESIVCLQKALNHLREIWELI...105122106138EEGETTILQLEKDLRTQVELMRKQKKERKQELK3ENST00000394249.81863ENST000003942493MRRSEVLAEESIVCLQKALNHLREIWELIGIPEDQRLQRTEVVKKH...proteinNoneENSP00000377793620787antisenseTGGCCTTTGACCCAGACATAATGGTGGCCA263-----------------MRRSEVLAEESIVCLQKALNHLREIWELI...262279263295WDRLQIPEEEREAVATIMSGSKAKVRKALQLEV4ENST00000361337.32298ENST000003613372MSGDHLHNDSQIEADFRLNDSHKHKDKHKDREHRHKEHKKEKDREK...proteinNoneENSP00000354522765420antisenseAAATACTCACTCATCCTCATCTCGAGGTCT140-----------------MSGDHLHNDSQIEADFRLNDSHKHKDKHK...139156140172GYFVPPKEDIKPLKRPRDEDDADYKPKKIKTEDLite ScoresYou now have all the information you need to calculate "lite" Target Scores, which are less data intensive than complete
target scores, with thepredict_targetfunction from thepredicttargmodule.lite_predictions = predict_target(design_df=design_df,
                                  aa_subseq_df=aa_subseq_df)
design_df['Target Score Lite'] = lite_predictions
design_df.head()/opt/anaconda3/envs/rs3/lib/python3.8/site-packages/sklearn/base.py:310: UserWarning: Trying to unpickle estimator SimpleImputer from version 1.0.dev0 when using version 0.24.2. This might lead to breaking code or invalid results. Use at your own risk.
  warnings.warn(
/opt/anaconda3/envs/rs3/lib/python3.8/site-packages/sklearn/base.py:310: UserWarning: Trying to unpickle estimator Pipeline from version 1.0.dev0 when using version 0.24.2. This might lead to breaking code or invalid results. Use at your own risk.
  warnings.warn(<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>InputQuotaTarget TaxonTarget Gene IDTarget Gene SymbolTarget TranscriptTarget Reference CoordsTarget AliasCRISPR MechanismTarget Domain...Off-Target Rank WeightCombined RankPreselected AsMatching Active Arrayed OligosMatching Arrayed ConstructsPools Containing Matching ConstructPick OrderPicking RoundPicking NotesTarget Score Lite0PSMB729606ENSG00000136930PSMB7ENST00000259457.8NaNNaNCRISPRkoCDS...1.07GCAGATACAAGAGCAACTGANaNBRDN0004619103NaN10Preselected0.0124671PSMB729606ENSG00000136930PSMB7ENST00000259457.8NaNNaNCRISPRkoCDS...1.048AAAACTGGCACGACCATCGCNaNNaNNaN20Preselected0.0483382PRC129606ENSG00000198901PRC1ENST00000394249.8NaNNaNCRISPRkoCDS...1.07AAAAGATTTGCGCACCCAAGNaNNaNNaN10Preselected-0.1292343PRC129606ENSG00000198901PRC1ENST00000394249.8NaNNaNCRISPRkoCDS...1.08CTTTGACCCAGACATAATGGNaNNaNNaN20Preselected0.0616474TOP129606ENSG00000198900TOP1ENST00000361337.3NaNNaNCRISPRkoCDS...1.01NaNNaNBRDN0001486452NaN21NaN-0.0091005 rows × 61 columnsIf you would like to calculate full target scores then follow the sections below.Protein domain inputTo calculate full target scores you will also need inputs for protein domains and conservation.The protein domain input should have 16 binary columns for 16 different protein domain sources in addition to theid_cols. The protein domain sources are 'Pfam', 'PANTHER', 'HAMAP', 'SuperFamily', 'TIGRfam', 'ncoils', 'Gene3D',
'Prosite_patterns', 'Seg', 'SignalP', 'TMHMM', 'MobiDBLite', 'PIRSF', 'PRINTS', 'Smart', 'Prosite_profiles'.
These columns should be kept in order when inputting for scoring.In this example we will load the protein domain information from a parquet file, which was written
usingwrite_transcript_datafunction in thetargetdatamodule. You can also query transcript data on the fly,
by using thebuild_translation_overlap_dffunction. See the documentation for thepredicttargmodule for more
information on how to do this.domain_df = pd.read_parquet('test_data/target_data/protein_domains.pq', engine='pyarrow',
                            filters=[[('Transcript Base', 'in', transcript_bases)]])
domain_df.head()<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>typecigar_stringidhit_endfeature_typedescriptionseq_region_nameendhit_starttranslation_idinterprohseqnameTranscript Basealign_typestart0PfamPF1246536protein_featureProteasome beta subunit, C-terminalENSP000002594572711976188IPR024689PF12465ENST00000259457None2351PfamPF00227190protein_featureProteasome, subunit alpha/betaENSP000002594572212976188IPR001353PF00227ENST00000259457None412PRINTSPR001410protein_featurePeptidase T1A, proteasome beta-subunitENSP00000259457660976188IPR000243PR00141ENST00000259457None513PRINTSPR001410protein_featurePeptidase T1A, proteasome beta-subunitENSP000002594571820976188IPR000243PR00141ENST00000259457None1714PRINTSPR001410protein_featurePeptidase T1A, proteasome beta-subunitENSP000002594571930976188IPR000243PR00141ENST00000259457None182Now to transform thedomain_dfinto a wide form for model input, we use theget_protein_domain_featuresfunction
from thetargetfeatmodule.domain_feature_df = get_protein_domain_features(design_targ_df, domain_df, id_cols=id_cols)
domain_feature_df.head()<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>sgRNA Context SequenceTarget Cut LengthTarget TranscriptOrientationPfamPANTHERHAMAPSuperFamilyTIGRfamncoilsGene3DProsite_patternsSegSignalPTMHMMMobiDBLitePIRSFPRINTSSmartProsite_profiles0AAAAGAATGATGAAAAGACACCACAGGGAG244ENST00000610426.5sense11000000000000001AAAAGAGCCATGAATCTAAACATCAGGAAT640ENST00000223073.6sense01000100100100002AAAAGCGCCAAATGGCCCGAGAATTGGGAG709ENST00000331923.9sense01000000000100003AAACAGAAAAAGTTAAAATCACCAAGGTGT496ENST00000283882.4sense01000000000000004AAACAGATGGAAGATGCTTACCGGGGGACC132ENST00000393047.8sense0100000000000000For input into thepredict_targetfunction, thedomain_feature_dfshould have theid_colsas well as
columns for each of the 16 protein domain features.Conservation inputFinally, for the full target model you need to calculate conservation features.
The conservation features represent conservation across evolutionary time at the sgRNA cut site and are quantified
using PhyloP scores. These scores are available for download by the UCSC genome browser
forhg38(phyloP100way),
andmm39(phyloP35way).Within this package we query conservation scores using the UCSC genome browser'sREST API.
To get conservation scores, you can use thebuild_conservation_dffunction from thetargetdatamodule.
Here we load conservation scores, which were written to parquet using thewrite_conservation_datafunction from thetargetdatamodule.conservation_df = pd.read_parquet('test_data/target_data/conservation.pq', engine='pyarrow',
                                  filters=[[('Transcript Base', 'in', transcript_bases)]])
conservation_df.head()<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>exon_idgenomic positionconservationTranscript Basetarget positionchromosomegenometranslation lengthTarget TranscriptStrand of TargetTarget Total Lengthranked_conservation0ENSE00001866322124415425.06.46189ENST0000025945719hg38277ENST00000259457.8-8340.6390891ENSE00001866322124415424.07.48071ENST0000025945729hg38277ENST00000259457.8-8340.6864512ENSE00001866322124415423.06.36001ENST0000025945739hg38277ENST00000259457.8-8340.6229023ENSE00001866322124415422.06.36001ENST0000025945749hg38277ENST00000259457.8-8340.6229024ENSE00001866322124415421.08.09200ENST0000025945759hg38277ENST00000259457.8-8340.870504We normalize conservation scores to a within-gene percent rank, in the 'ranked_conservation' column,
in order to make scores comparable across genes and genomes. Note that a rank of 0 indicates the
least conserved nucleotide and a rank of 1 indicates the most conserved.To featurize the conservation scores, we average across a window of 4 and 32 nucleotides
centered around the nucleotide preceding the cut site in the direction of transcription.
Note that this nucleotide is the 2nd nucleotide in the window of 4 and the 16th nucleotide in the window of 32.We use theget_conservation_featuresfunction from thetargetfeatmodule to get these features from theconservation_df.For thepredict_targfunction, we need theid_colsand the columns 'cons_4' and 'cons_32' in theconservation_feature_df.conservation_feature_df = get_conservation_features(design_targ_df, conservation_df,
                                                    small_width=2, large_width=16,
                                                    conservation_column='ranked_conservation',
                                                    id_cols=id_cols)
conservation_feature_df<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>sgRNA Context SequenceTarget Cut LengthTarget TranscriptOrientationcons_4cons_320AAAAGAATGATGAAAAGACACCACAGGGAG244ENST00000610426.5sense0.2182310.4088441AAAAGAGCCATGAATCTAAACATCAGGAAT640ENST00000223073.6sense0.1298250.2781802AAAAGCGCCAAATGGCCCGAGAATTGGGAG709ENST00000331923.9sense0.4709060.5323053AAACAGAAAAAGTTAAAATCACCAAGGTGT496ENST00000283882.4sense0.5805560.6027084AAACAGATGGAAGATGCTTACCGGGGGACC132ENST00000393047.8sense0.2834470.414293.....................395TTTGATTGCATTAAGGTTGGACTCTGGATT246ENST00000249269.9sense0.5806120.618707396TTTGCCCACAGCTCCAAAGCATCGCGGAGA130ENST00000227618.8sense0.3237700.416368397TTTTACAGTGCGATGTATGATGTATGGCTT119ENST00000338366.6sense0.7880000.537417398TTTTGGATCTCGTAGTGATTCAAGAGGGAA233ENST00000629496.3sense0.2396300.347615399TTTTTGTTACTACAGGTTCGCTGCTGGGAA201ENST00000395840.6sense0.6937670.639044400 rows × 6 columnsFull Target ScoresIn order to calculate Target Scores you must input the feature matrices and design_df to thepredict_targetfunction from thepredicttargmodule.target_predictions = predict_target(design_df=design_df,
                                    aa_subseq_df=aa_subseq_df,
                                    domain_feature_df=domain_feature_df,
                                    conservation_feature_df=conservation_feature_df,
                                    id_cols=id_cols)
design_df['Target Score'] = target_predictions
design_df.head()/opt/anaconda3/envs/rs3/lib/python3.8/site-packages/sklearn/base.py:310: UserWarning: Trying to unpickle estimator SimpleImputer from version 1.0.dev0 when using version 0.24.2. This might lead to breaking code or invalid results. Use at your own risk.
  warnings.warn(
/opt/anaconda3/envs/rs3/lib/python3.8/site-packages/sklearn/base.py:310: UserWarning: Trying to unpickle estimator Pipeline from version 1.0.dev0 when using version 0.24.2. This might lead to breaking code or invalid results. Use at your own risk.
  warnings.warn(<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>InputQuotaTarget TaxonTarget Gene IDTarget Gene SymbolTarget TranscriptTarget Reference CoordsTarget AliasCRISPR MechanismTarget Domain...Combined RankPreselected AsMatching Active Arrayed OligosMatching Arrayed ConstructsPools Containing Matching ConstructPick OrderPicking RoundPicking NotesTarget Score LiteTarget Score0PSMB729606ENSG00000136930PSMB7ENST00000259457.8NaNNaNCRISPRkoCDS...7GCAGATACAAGAGCAACTGANaNBRDN0004619103NaN10Preselected0.0124670.1520371PSMB729606ENSG00000136930PSMB7ENST00000259457.8NaNNaNCRISPRkoCDS...48AAAACTGGCACGACCATCGCNaNNaNNaN20Preselected0.0483380.0648802PRC129606ENSG00000198901PRC1ENST00000394249.8NaNNaNCRISPRkoCDS...7AAAAGATTTGCGCACCCAAGNaNNaNNaN10Preselected-0.129234-0.0630123PRC129606ENSG00000198901PRC1ENST00000394249.8NaNNaNCRISPRkoCDS...8CTTTGACCCAGACATAATGGNaNNaNNaN20Preselected0.061647-0.1263574TOP129606ENSG00000198900TOP1ENST00000361337.3NaNNaNCRISPRkoCDS...1NaNNaNBRDN0001486452NaN21NaN-0.009100-0.2344105 rows × 62 columnsTarget Scores can be added directly to the sequence scores for your final Rule Set 3 predictions.Predict FunctionIf you don't want to generate the target matrices themselves, you can use thepredictfunction from
thepredictmodule.from rs3.predict import predict
import matplotlib.pyplot as plt
import gpplot
import seaborn as snsPreloaded dataIn this first example with thepredictfunction, we calculate predictions for GeckoV2 sgRNAs.In this example the amino acid sequences, protein domains and conservation scores were prequeried using thewrite_transcript_dataandwrite_conservation_datafunctions from the targetdata module.
Pre-querying these data can be helpful for large scale design runs.You can also use thepredictfunction without pre-querying and calculate
scores on the fly. You can see an example of this in the next section.Thepredictfunction allows for parallel computation
for querying databases (n_jobs_min) and featurizing sgRNAs (n_jobs_max).
We recommend keepingn_jobs_minset to 1 or 2, as the APIs limit the amount of queries per hour.design_df = pd.read_table('test_data/sgrna-designs.txt')
import multiprocessing
max_n_jobs = multiprocessing.cpu_count()scored_designs = predict(design_df, tracr=['Hsu2013', 'Chen2013'], target=True,
                         n_jobs_min=2, n_jobs_max=max_n_jobs,
                         aa_seq_file='./test_data/target_data/aa_seqs.pq',
                         domain_file='./test_data/target_data/protein_domains.pq',
                         conservatin_file='./test_data/target_data/conservation.pq',
                         lite=False)
scored_designs.head()Calculating sequence-based features


100%|██████████| 400/400 [00:05<00:00, 68.98it/s] 


Calculating sequence-based features


100%|██████████| 400/400 [00:01<00:00, 229.85it/s]
/opt/anaconda3/envs/rs3/lib/python3.8/site-packages/sklearn/base.py:310: UserWarning: Trying to unpickle estimator SimpleImputer from version 1.0.dev0 when using version 0.24.2. This might lead to breaking code or invalid results. Use at your own risk.
  warnings.warn(
/opt/anaconda3/envs/rs3/lib/python3.8/site-packages/sklearn/base.py:310: UserWarning: Trying to unpickle estimator Pipeline from version 1.0.dev0 when using version 0.24.2. This might lead to breaking code or invalid results. Use at your own risk.
  warnings.warn(<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>InputQuotaTarget TaxonTarget Gene IDTarget Gene SymbolTarget TranscriptTarget Reference CoordsTarget AliasCRISPR MechanismTarget Domain...Picking RoundPicking NotesRS3 Sequence Score (Hsu2013 tracr)RS3 Sequence Score (Chen2013 tracr)AA IndexTranscript BaseMissing conservation informationTarget ScoreRS3 Sequence (Hsu2013 tracr) + Target ScoreRS3 Sequence (Chen2013 tracr) + Target Score0PSMB729606ENSG00000136930PSMB7ENST00000259457.8NaNNaNCRISPRkoCDS...0Preselected0.7876400.55934564ENST00000259457False0.1520370.9396760.7113811PSMB729606ENSG00000136930PSMB7ENST00000259457.8NaNNaNCRISPRkoCDS...0Preselected-0.294126-0.18143746ENST00000259457False0.064880-0.229246-0.1165572PRC129606ENSG00000198901PRC1ENST00000394249.8NaNNaNCRISPRkoCDS...0Preselected-0.043418-0.220434106ENST00000394249False-0.063012-0.106429-0.2834463PRC129606ENSG00000198901PRC1ENST00000394249.8NaNNaNCRISPRkoCDS...0Preselected0.7592560.453469263ENST00000394249False-0.1263570.6328990.3271124TOP129606ENSG00000198900TOP1ENST00000361337.3NaNNaNCRISPRkoCDS...1NaN0.424001-0.197035140ENST00000361337False-0.2344100.189591-0.4314455 rows × 68 columnsHere are the details for the keyword arguments of the above functiontracr- tracr to calculate scores for. If a list is supplied instead of a string, scores will be calculated for both tracrstarget- boolean indicating whether to calculate target scoresn_jobs_min,n_jobs_max- number of cpus to use for parallel computationaa_seq_file,domain_file,conservatin_file- precalculated parquet files. Optional inputs as these features can also be calculated on the flylite- boolean indicating whether to calculate lite target scoresBy listing both tracrRNAstracr=['Hsu2013', 'Chen2013']and settingtarget=True,
we calculate 5 unique scores: one sequence score for each tracr, the target score,
and the sequence scores plus the target score.We can compare these predictions against the observed activity from GeckoV2gecko_activity = pd.read_csv('test_data/Aguirre2016_activity.csv')
gecko_activity.head()<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>sgRNA SequencesgRNA Context SequenceTarget Gene SymbolTarget Cut %avg_mean_centered_neg_lfc0AAAAAACTTACCCCTTTGACAAAAAAAAAACTTACCCCTTTGACTGGCCACPSF622.2-1.1398191AAAAACATTATCATTGAGCCTGGCAAAAACATTATCATTGAGCCTGGATTSKA362.3-0.7930552AAAAAGAGATTGTCAAATCATATGAAAAAGAGATTGTCAAATCAAGGTAGAQR3.80.9464533AAAAAGCATCTCTAGAAATATTCAAAAAAGCATCTCTAGAAATATGGTCCZNHIT661.7-0.4295904AAAAAGCGAGATACCCGAAAAAAAAAAAAGCGAGATACCCGAAAAGGCAGABCF19.40.734196gecko_activity_scores = (gecko_activity.merge(scored_designs,
                                              how='inner',
                                              on=['sgRNA Sequence', 'sgRNA Context Sequence',
                                                  'Target Gene Symbol', 'Target Cut %']))
gecko_activity_scores.head()<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>sgRNA SequencesgRNA Context SequenceTarget Gene SymbolTarget Cut %avg_mean_centered_neg_lfcInputQuotaTarget TaxonTarget Gene IDTarget Transcript...Picking RoundPicking NotesRS3 Sequence Score (Hsu2013 tracr)RS3 Sequence Score (Chen2013 tracr)AA IndexTranscript BaseMissing conservation informationTarget ScoreRS3 Sequence (Hsu2013 tracr) + Target ScoreRS3 Sequence (Chen2013 tracr) + Target Score0AAAACTGGCACGACCATCGCCCGGAAAACTGGCACGACCATCGCTGGGGTPSMB716.4-1.052943PSMB729606ENSG00000136930ENST00000259457.8...0Preselected-0.294126-0.18143746ENST00000259457False0.064880-0.229246-0.1165571AAAAGATTTGCGCACCCAAGTAGAAAAAGATTTGCGCACCCAAGTGGAATPRC117.00.028674PRC129606ENSG00000198901ENST00000394249.8...0Preselected-0.043418-0.220434106ENST00000394249False-0.063012-0.106429-0.2834462AAAAGTCCAAGCATAGCAACCGGGAAAAGTCCAAGCATAGCAACAGGTAATOP16.50.195309TOP129606ENSG00000198900ENST00000361337.3...0Preselected-0.294127-0.02295150ENST00000361337False-0.354708-0.648835-0.3776593AAAGAAGCCTCAACTTCGTCAGCGAAAGAAGCCTCAACTTCGTCTGGAGACENPW37.5-1.338209CENPW29606ENSG00000203760ENST00000368328.5...0Preselected-0.667399-0.30879434ENST00000368328False0.129285-0.538114-0.1795094AAAGTGTGCTTTGTTGGAGATACTAAAGTGTGCTTTGTTGGAGATGGCTTNSA260.0-0.175219NSA229606ENSG00000164346ENST00000610426.5...0Preselected-0.402220-0.622492157ENST00000610426False-0.113577-0.515797-0.7360695 rows × 69 columnsSince GeckoV2 was screened with the tracrRNA from Hsu et al. 2013, we'll use these scores sequence scores a part of our final prediction.plt.subplots(figsize=(4,4))
gpplot.point_densityplot(gecko_activity_scores, y='avg_mean_centered_neg_lfc',
                         x='RS3 Sequence (Hsu2013 tracr) + Target Score')
gpplot.add_correlation(gecko_activity_scores, y='avg_mean_centered_neg_lfc',
                       x='RS3 Sequence (Hsu2013 tracr) + Target Score')
sns.despine()Predictions on the flyYou can also make predictions without pre-querying the target data. Here
we use example designs for BCL2L1, MCL1 and EEF2.design_df = pd.read_table('test_data/sgrna-designs_BCL2L1_MCL1_EEF2.txt')scored_designs = predict(design_df,
                         tracr=['Hsu2013', 'Chen2013'], target=True,
                         n_jobs_min=2, n_jobs_max=8,
                         lite=False)
scored_designsCalculating sequence-based features


100%|██████████| 849/849 [00:06<00:00, 137.86it/s]


Calculating sequence-based features


100%|██████████| 849/849 [00:02<00:00, 321.44it/s]


Getting amino acid sequences


100%|██████████| 1/1 [00:00<00:00,  1.77it/s]


Getting protein domains


100%|██████████| 3/3 [00:00<00:00, 899.29it/s]


Getting conservation


100%|██████████| 3/3 [00:00<00:00, 10.67it/s]
/opt/anaconda3/envs/rs3/lib/python3.8/site-packages/sklearn/base.py:310: UserWarning: Trying to unpickle estimator SimpleImputer from version 1.0.dev0 when using version 0.24.2. This might lead to breaking code or invalid results. Use at your own risk.
  warnings.warn(
/opt/anaconda3/envs/rs3/lib/python3.8/site-packages/sklearn/base.py:310: UserWarning: Trying to unpickle estimator Pipeline from version 1.0.dev0 when using version 0.24.2. This might lead to breaking code or invalid results. Use at your own risk.
  warnings.warn(<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>InputQuotaTarget TaxonTarget Gene IDTarget Gene SymbolTarget TranscriptTarget AliasCRISPR MechanismTarget DomainReference Sequence...Picking RoundPicking NotesRS3 Sequence Score (Hsu2013 tracr)RS3 Sequence Score (Chen2013 tracr)AA IndexTranscript BaseMissing conservation informationTarget ScoreRS3 Sequence (Hsu2013 tracr) + Target ScoreRS3 Sequence (Chen2013 tracr) + Target Score0EEF259606ENSG00000167658EEF2ENST00000309311.7NaNCRISPRkoCDSNC_000019.10...NaNOutside Target Window: 5-65%0.9078090.769956666ENST00000309311False-0.1155490.7922610.6544081EEF259606ENSG00000167658EEF2ENST00000309311.7NaNCRISPRkoCDSNC_000019.10...NaNBsmBI:CGTCTC; Outside Target Window: 5-65%0.1718700.040419581ENST00000309311False-0.0176430.1542260.0227762EEF259606ENSG00000167658EEF2ENST00000309311.7NaNCRISPRkoCDSNC_000019.10...1.0NaN1.3935130.577732107ENST00000309311False0.1729101.5664220.7506423EEF259606ENSG00000167658EEF2ENST00000309311.7NaNCRISPRkoCDSNC_000019.10...1.0NaN0.9044460.008390406ENST00000309311False0.1210341.0254800.1294244EEF259606ENSG00000167658EEF2ENST00000309311.7NaNCRISPRkoCDSNC_000019.10...1.0NaN0.8310870.361594546ENST00000309311False0.0360410.8671280.397635..................................................................844MCL159606ENSG00000143384MCL1ENST00000369026.3NaNCRISPRkoCDSNC_000001.11...NaNOff-target Match Bin I matches > 3; Spacing Vi...-0.792918-0.66388152ENST00000369026False-0.299583-1.092501-0.963464845MCL159606ENSG00000143384MCL1ENST00000369026.3NaNCRISPRkoCDSNC_000001.11...NaNOutside Target Window: 5-65%; poly(T):TTTT-1.920374-1.8199855ENST00000369026False-0.003507-1.923881-1.823491846MCL159606ENSG00000143384MCL1ENST00000369026.3NaNCRISPRkoCDSNC_000001.11...NaNSpacing Violation: Too close to earlier pick a...-1.101303-1.29564024ENST00000369026False-0.285485-1.386788-1.581125847MCL159606ENSG00000143384MCL1ENST00000369026.3NaNCRISPRkoCDSNC_000001.11...NaNSpacing Violation: Too close to earlier pick a...-0.617431-0.62143630ENST00000369026False-0.312348-0.929779-0.933784848MCL159606ENSG00000143384MCL1ENST00000369026.3NaNCRISPRkoCDSNC_000001.11...NaNOn-Target Efficacy Score < 0.2; Spacing Violat...-0.586811-0.66413030ENST00000369026False-0.312348-0.899159-0.976478849 rows × 61 columnsWe see that the predict function is querying the target data in addition
to making predictions.