ddmc.datasets¶
Loaders for the mass-spec datasets bundled with the package, plus preprocessing helpers for filtering peptides by missingness.
ddmc.datasets ¶
Loaders for the mass-spec datasets bundled with the package.
Contains
CPTAC: the CPTAC lung cancer clinical phosphoproteomics cohort, plus accompanying clinical metadata (mutation calls, tumor/NAT status, hot/cold immune infiltration labels) used in the DDMC paper.EBDT: the MCF7 kinase-inhibitor phosphoproteomics dataset from Hijazi et al., Nat Biotechnol 2020, remapped onto DDMC's length-11 sequence-motif representation.filter_incomplete_peptides/select_peptide_subset: preprocessing helpers for filtering ap_signalDataFrame by missingness or down to a random subset of peptides, for use beforeddmc.clustering.DDMC.fit.
CPTAC ¶
Loader for the CPTAC lung cancer clinical phosphoproteomics cohort and its accompanying clinical metadata.
Sample columns throughout this dataset are patient IDs, with tumor
samples given plain (e.g. "C3L.00001") and their matched adjacent
normal tissue (NAT) samples suffixed with ".N" (e.g. "C3L.00001.N").
get_hot_cold_labels ¶
get_hot_cold_labels() -> pd.Series
Load per-patient immune infiltration ("hot"/"cold" tumor) labels.
Tumor samples labeled "NAT enriched" (ambiguous/mixed signal) are dropped, as are NAT samples themselves (this label only applies to tumor samples).
Returns:
| Type | Description |
|---|---|
Series
|
Boolean Series indexed by patient ID, True for immunologically |
Series
|
"hot" tumors ("Hot-tumor enriched") and False for "cold" tumors |
Series
|
("Cold-tumor enriched"). |
Source code in ddmc/datasets.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
get_mutations ¶
get_mutations(
mutation_names: Sequence[str] | None = None,
) -> pd.DataFrame
Load per-patient genetic mutation calls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mutation_names
|
Sequence[str] | None
|
If given, restrict the result to these mutation
columns (as named in |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Boolean DataFrame indexed by patient ID (restricted to patients |
DataFrame
|
with both a tumor and NAT sample), with one column per |
DataFrame
|
mutation, True where that patient carries the mutation. |
Source code in ddmc/datasets.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
get_p_signal ¶
get_p_signal(min_experiments: int = 2) -> pd.DataFrame
Load the CPTAC phosphorylation signal matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_experiments
|
int
|
The minimum number of TMT experiments a
peptide must be observed in to be kept; passed to
|
2
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame of phosphorylation signal, indexed by the length-11 |
DataFrame
|
peptide sequence, with one column per sample. |
Source code in ddmc/datasets.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
get_patients_with_nat_and_tumor ¶
get_patients_with_nat_and_tumor(samples) -> np.ndarray
Get patients that have both NAT and tumor samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
samples
|
Sequence[str] | ndarray
|
Sample identifiers to
consider (tumor samples plain, NAT samples suffixed with
|
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Sorted array of patient IDs (the tumor-sample form, without |
ndarray
|
|
Source code in ddmc/datasets.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
get_sample_to_experiment ¶
get_sample_to_experiment(
as_df: Literal[False] = False,
) -> np.ndarray
get_sample_to_experiment(
as_df: Literal[True],
) -> pd.DataFrame
get_sample_to_experiment(
as_df: bool = False,
) -> np.ndarray | pd.DataFrame
Load the mapping from sample to the TMT experiment it was run in.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
as_df
|
bool
|
If True, return the raw DataFrame read from
|
False
|
Returns:
| Type | Description |
|---|---|
ndarray | DataFrame
|
If |
ndarray | DataFrame
|
array of shape |
ndarray | DataFrame
|
identifier, aligned to that CSV's row order. |
Source code in ddmc/datasets.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
get_tumor_or_nat ¶
get_tumor_or_nat(
samples: Sequence[str] | Index,
) -> np.ndarray
Get tumor vs NAT for each of samples. Returned array contains True if tumor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
samples
|
Sequence[str] | Index
|
Sample identifiers (tumor samples plain, NAT samples
suffixed with |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Boolean array of shape |
ndarray
|
True where the sample is a tumor sample (not NAT). |
Source code in ddmc/datasets.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |
EBDT ¶
Loader for the MCF7 kinase-inhibitor phosphoproteomics dataset from Hijazi et al., Nat Biotechnol 2020. Each sample column is the fold-change in phosphorylation signal for MCF7 cells treated with a given kinase inhibitor, relative to control.
get_p_signal ¶
get_p_signal() -> pd.DataFrame
Load the EBDT phosphorylation fold-change matrix.
Reads the raw per-site CSV, maps each site onto the human proteome
to build DDMC's length-11 sequence-motif representation (via
pos_to_motif), and drops any site that fails to map.
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame of phosphorylation fold-change, indexed by the |
DataFrame
|
length-11 peptide sequence, with one column per inhibitor |
DataFrame
|
treatment. |
Source code in ddmc/datasets.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | |
pos_to_motif ¶
pos_to_motif(
genes: Sequence[str], pos: Sequence[str]
) -> tuple[list[str], list[list[str]]]
Map p-site sequence position to uniprot's proteome and extract motifs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
genes
|
Sequence[str]
|
Gene name for each phosphosite (used to look up the protein sequence in the UniProt proteome). |
required |
pos
|
Sequence[str]
|
Phosphosite position for each entry, formatted as the
phosphoacceptor residue letter followed by its 1-indexed
position in the protein (e.g. |
required |
Returns:
| Type | Description |
|---|---|
tuple[list[str], list[list[str]]]
|
A tuple |
Source code in ddmc/datasets.py
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
filter_incomplete_peptides ¶
filter_incomplete_peptides(
p_signal: DataFrame,
sample_presence_ratio: float | None = None,
min_experiments: int | None = None,
sample_to_experiment: ndarray | None = None,
) -> pd.DataFrame
Filters out missing values from p-signal array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_presence_ratio
|
float | None
|
the minimum fraction of non-missing values allowed for a peptide before it is DROPPED. |
None
|
min_experiments
|
int | None
|
the minimum number of experiments allowed for a peptide before it is DROPPED. Must also pass in sample_to_experiment. |
None
|
sample_to_experiment
|
ndarray | None
|
array of shape |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Filtered data. |
Source code in ddmc/datasets.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
select_peptide_subset ¶
select_peptide_subset(
p_signal: DataFrame,
keep_ratio: float | None = None,
keep_num: int | None = None,
) -> pd.DataFrame
Selects a random subset of peptides from p_signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p_signal
|
DataFrame
|
Phosphorylation signal, indexed by peptide sequence. |
required |
keep_ratio
|
float | None
|
Fraction of peptides to keep; if given, overrides
|
None
|
keep_num
|
int | None
|
Number of peptides to keep. Required if |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
A random subset of the rows of |
DataFrame
|
replacement), of shape (keep_num, p_signal.shape[1]). |
Source code in ddmc/datasets.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |