crispr_analysis_utils.guide_annotation.annotate¶
crispr_analysis_utils.guide_annotation.annotate ¶
Place each aligned site in a gene: genic or intergenic, exon or intron.
Overlaps are decided on the protospacer, so a guide reaching into an exon counts as exonic. Distances and the position along a CDS are measured from the target site, which is where the break falls.
Every interval operation ignores strand: a guide on one strand targets a gene on either.
DELIMITER
module-attribute
¶
DELIMITER = ';'
Separates the ids in a list-valued column.
A semicolon rather than a comma, because a comma already separates ids inside
the IGVF format's own putative_target_genes.
FEATURES
module-attribute
¶
FEATURES = (EXON, INTRON)
Where a site falls, in the order qc.tsv counts them.
SITE_COLUMNS
module-attribute
¶
SITE_COLUMNS = ('chr', 'start', 'end', 'strand', 'target_site')
What annotate_sites needs of every site.
DISTANCE_FROM
module-attribute
¶
DISTANCE_FROM = (MIDPOINT, TARGET_SITE)
Where a distance is measured from.
The midpoint of the protospacer by default. A dCas9 occupies the whole
protospacer rather than acting at one base, so its centre is the more honest
reference for how far a guide sits from a TSS. target_site measures from
the boundary 3 bases 5' of the PAM instead, which is where a nuclease cuts.
AnnotationError ¶
Bases: RuntimeError
The sites and the annotation cannot be compared at all.
Source code in src/crispr_analysis_utils/guide_annotation/annotate.py
57 58 | |
annotate_sites ¶
annotate_sites(sites: DataFrame, store: Store, promoters: DataFrame, *, promoter_window: int = 1000, distance_from: str = MIDPOINT) -> pd.DataFrame
Annotate every site against the genes of the store.
Parameters:
-
sites(DataFrame) –One row per site, with
SITE_COLUMNSat least. Any other column is carried through to the output untouched. -
store(Store) –The annotation store, as
load_storereturns it. -
promoters(DataFrame) –Transcription start sites, as
read_promotersreturns them. -
promoter_window(int, default:1000) –How far either side of a TSS counts as its promoter.
Returns:
-
DataFrame–One row per site per overlapping gene; a site in no gene keeps one row,
intergenic, with the gene columns empty. The input's own columns come first.
Raises:
-
AnnotationError–No site contig appears in the store, so nothing could ever overlap.
Source code in src/crispr_analysis_utils/guide_annotation/annotate.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |