Regions
chromatinhd.data.Regions
Bases: Flow
Regions in the genome
Source code in src/chromatinhd/data/regions.py
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 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
coordinates = TSV(columns=['chrom', 'start', 'end'])
class-attribute
instance-attribute
Coordinates dataframe of the regions, with columns chrom, start, end
width = window_width
class-attribute
instance-attribute
Width of the regions, None if regions do not have a fixed width
filter(region_ids, path=None, overwrite=True)
Select a subset of regions
Parameters:
Name | Type | Description | Default |
---|---|---|---|
region_ids
|
List[str]
|
Genes to filter. Should be a pandas Series with the index being the ensembl transcript ids. |
required |
path
|
PathLike
|
Path to store the filtered regions |
None
|
Returns: Regions with only the specified region_ids
Source code in src/chromatinhd/data/regions.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
from_chromosomes_file(chromosomes_file, path=None, filter_chromosomes=True, overwrite=True)
classmethod
Create regions based on a chromosomes file, e.g. hg38.chrom.sizes
Parameters:
Name | Type | Description | Default |
---|---|---|---|
chromosomes_file
|
PathLike
|
Path to chromosomes file, tab separated, with columns chrom, size |
required |
path
|
PathLike
|
Folder in which the regions data will be stored |
None
|
Returns: Regions
Source code in src/chromatinhd/data/regions.py
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 |
|
from_transcripts(transcripts, window, path=None, max_n_regions=None, overwrite=True)
classmethod
Create regions from a dataframe of transcripts, using a specified window around each transcription start site.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transcripts
|
DataFrame
|
Dataframe of transcripts, with columns chrom, start, end, strand, transcript |
required |
window
|
[list, ndarray]
|
Window around each transcription start site. Should be a 2-element array, e.g. [-10000, 10000] |
required |
path
|
PathLike
|
Folder in which the regions data will be stored |
None
|
max_n_regions
|
Optional[int]
|
Maximum number of region to use. If None, all regions are used. |
None
|
Returns: Regions
Source code in src/chromatinhd/data/regions.py
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 |
|
chromatinhd.data.regions.select_tss_from_fragments(transcripts, fragments_file, window=(-100, 100))
Select the TSS with the most fragments within a window of the TSS
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transcripts
|
DataFrame
|
Dataframe of transcripts, with columns chrom, tss, ensembl_gene_id. |
required |
fragments_file
|
PathLike
|
Path to fragments file |
required |
window
|
[ndarray, tuple]
|
Window around the TSS to count fragments |
(-100, 100)
|
Returns: Dataframe of transcripts, with columns chrom, tss and n_fragments, with index being the gene id
Source code in src/chromatinhd/data/regions.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
|