models
Coverage
Object describing layout and coverage of peptides and generating the corresponding matrices. Peptides should all belong to the same state and have the same exposure time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
DataFrame
|
DataFrame with input peptides |
required |
n_term
|
Optional[int]
|
Residue index of the N-terminal residue. Default value is 1, can be negative to accommodate for N-terminal purification tags |
None
|
c_term
|
Optional[int]
|
Residue index number of the C-terminal residue (where first residue has index number 1) |
None
|
sequence
|
Optional[str]
|
Amino acid sequence of the protein in one-letter FASTA encoding. Optional, if not specified the amino acid sequence from the peptide data is used to (partially) reconstruct the sequence. Supplied amino acid sequence must be compatible with sequence information in the peptides. |
None
|
Source code in pyhdx/models.py
28 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 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 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
|
Np
property
Number of peptides.
Nr
property
Total number of residues spanned by the peptides.
X = np.zeros((len(self.data), self.interval[1] - self.interval[0]), dtype=int)
instance-attribute
Np x Nr matrix (peptides x residues). Values are 1 where residue j is in peptide i.
X_norm
property
X
coefficient matrix normalized column-wise.
Z = self.Z / self.data['ex_residues'].to_numpy()[:, np.newaxis]
instance-attribute
Np x Nr matrix (peptides x residues). Values are 1/(ex_residues) where residue j is in peptide i.
Z_norm
property
Z
Coefficient matrix normalized column-wise.
avg_peptide_length
property
Average length of the peptides
block_length
property
Lengths of unique blocks of residues in the peptides map, along the r_number
axis
index
property
Pandas index of residue numbers corresponding to the part of the protein covered by peptides.
percent_coverage
property
Percentage of residues covered by peptides
r_number
property
Pandas index numbers corresponding to the part of the protein covered by peptides
redundancy
property
Average redundancy of peptides in regions with at least 1 peptide
__getitem__(item)
Gets columns from underlying protein and crops to interval.
Crop interval is equal to the coverage range of peptides in this :class:.Coverage
object.
Source code in pyhdx/models.py
106 107 108 109 110 111 112 113 114 |
|
apply_interval(array_or_series)
Returns the section of array_or_series
in the interval
Given a Numpy array or Pandas series with a length equal to the full protein, returns the section of the array equal to the covered region. Returned series length is equal to number of columns in the X matrix
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array_or_series
|
Union[ndarray, Series]
|
Input data object to crop to interval |
required |
Returns:
Type | Description |
---|---|
Series
|
Input object cropped to interval of the interval spanned by the peptides |
Source code in pyhdx/models.py
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 |
|
get_sections(gap_size=-1)
Get the intervals of independent sections of coverage.
Intervals are inclusive, exclusive.
Gaps are defined with gap_size
, adjacent peptides with distances bigger than this value are considered not to
overlap. Set to -1 to treat touching peptides as belonging to the same section.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gap_size
|
int
|
The size which defines a gap |
-1
|
Source code in pyhdx/models.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
|
CoverageSet
Coverage object for multiple HDXMeasurement objects.
This objects finds the minimal interval of residue numbers which fit all :class:.HDXMeasurement
s
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hdxm_list
|
list[HDXMeasurement]
|
List of input HDXMeasurment objects. |
required |
Source code in pyhdx/models.py
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 |
|
index
property
Index of residue numbers
apply_interval(array_or_series)
Given a Numpy array or Pandas series with a length equal to the full protein, returns the section of the array equal to the covered region. Returned series length is equal to number of columns in the X matrix
Source code in pyhdx/models.py
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 |
|
get_masks()
Get boolean masks along the different data dimensions which are True
at elements
which have measured data.
The masks can be used to assign values to the quantity tensors (k_int, X, D_exp, ect) used for calculating D-uptake from ΔG.
Returns:
Type | Description |
---|---|
dict[str, ndarray]
|
Dictionary of boolean masks spanning the various data dimensions. |
Returned masks and shapes:
- sr_mask:
(Ns, Nr)
- st_mask:
(Ns, Nt)
- spt_mask:
(Ns, Np, Nr)
- spt_mask:
(Ns, Np, Nt)
Source code in pyhdx/models.py
734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 |
|
HDXMeasurement
Main HDX data object.
This object has peptide data of a single state and with multiple timepoints.
Timepoint data is split into HDXTimepoint
objects for
each timepoint. Supplied data is made 'uniform' such that all timepoints have the same peptides.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
DataFrame
|
Dataframe with all peptides belonging to a single state. |
required |
**metadata
|
Any
|
Dictionary of optional metadata. By default, holds the |
{}
|
Attributes:
Name | Type | Description |
---|---|---|
coverage |
Coverage
|
Coverage object describing peptide layout. |
data |
DataFrame
|
DataFrame with all peptides, taking only peptides present in all timepoints. |
peptides |
list[HDXTimepoint]
|
List of |
state |
str
|
Protein state label for this HDX measurement. |
timepoints |
ndarray
|
Deuterium exposure times. |
Source code in pyhdx/models.py
224 225 226 227 228 229 230 231 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 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 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 378 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 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 |
|
Np
property
Number of peptides.
Nr
property
Total number of residues spanned by the peptides.
Nt
property
Number of timepoints.
d_exp
property
D-uptake values (corrected for back-exchange).
Shape of the returned DataFrame is (Np, Nt)
.
name
property
HDX Measurement name.
pH
property
pH of the H/D exchange reaction.
rfu_peptides
property
Relative fractional uptake per peptide.
Shape of the returned DataFrame is (Np, Nt)
.
rfu_residues
property
Relative fractional uptake per residue.
Shape of the returned DataFrame is (Nr, Nt)
.
rfu_residues_sd
property
Standard deviations of relative fractional uptake per residue.
Shape of the returned DataFrame is (Nr, Nt)
.
temperature
property
Temperature of the H/D exchange reaction (K).
__str__()
String representation of this HDX measurement object.
Returns:
Type | Description |
---|---|
str
|
Multiline string describing this HDX Measurement object |
Source code in pyhdx/models.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
|
from_dataset(dataset, state, drop_first=cfg.analysis.drop_first, **metadata)
classmethod
Create an HDXMeasurement object from a HDXDataSet object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
HDXDataSet
|
HDXDataSet object |
required |
state
|
str | int
|
State label or index for measurement in the dataset |
required |
Returns:
Type | Description |
---|---|
HDXMeasurement
|
HDXMeasurement object. |
Source code in pyhdx/models.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
|
get_tensors(exchanges=False, dtype=cfg.TORCH_DTYPE)
Returns a dictionary of tensor variables for fitting HD kinetics.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exchanges
|
bool
|
If |
False
|
dtype
|
Optional[dtype]
|
Optional Torch data type. Use torch.float32 for faster fitting of large data sets, possibly at the expense of accuracy. |
TORCH_DTYPE
|
Returns:
Type | Description |
---|---|
dict[str, Tensor]
|
Dictionary with tensors. |
Tensor output and shapes:
- temperature
(1, 1)
- X
(Np, Nr)
- k_int
(Nr, 1)
- timepoints
(1, Nt)
- d_exp
(Np, Nt)
Source code in pyhdx/models.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
|
guess_deltaG(rates, correct_c_term=True)
Obtain ΔG initial guesses from apparent H/D exchange rates.
Units of rates are per second.
As the intrinsic rate of exchange of the c-terminal residue is ~100 fold lower,
guess values for PF and ΔG are also much lower. Use the option correct_c_term
to
set the c-terminal guess value equal to the value of the residue preceding it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rates
|
Series
|
Apparent exchange rates (units s-1). Series index is protein residue number. |
required |
correct_c_term
|
bool
|
If |
True
|
Returns:
Type | Description |
---|---|
Series
|
ΔG guess values (units kJ/mol) |
Source code in pyhdx/models.py
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
|
to_file(file_path, include_version=True, include_metadata=True, fmt='csv', **kwargs)
Write the data in this HDXMeasurement to file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
PathLike
|
File path to create and write to. |
required |
include_version
|
bool
|
Set to |
True
|
fmt
|
str
|
Formatting to use, options are 'csv' or 'pprint' |
'csv'
|
include_metadata
|
bool
|
If |
True
|
**kwargs
|
Any
|
Optional additional keyword arguments passed to |
{}
|
Source code in pyhdx/models.py
537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 |
|
HDXMeasurementSet
Set of multiple HDXMeasurement objects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hdxm_list
|
list[HDXMeasurement]
|
Input list of HDX measurements. |
required |
Attributes:
Name | Type | Description |
---|---|---|
coverage |
CoverageSet
|
Coverage object for the set of measurements. |
d_exp |
ndarray
|
Array with measured D-uptake values, padded with zeros. Shape is |
timepoints |
ndarray
|
Array with timepoints, padded with zeros in case of samples with
unequal number of timepoints. Shape is |
Source code in pyhdx/models.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 |
|
Np
property
Number of peptides
Nr
property
Number of residues
Ns
property
Number of samples
Nt
property
Number of timepoints
exchanges
property
Boolean mask for residues which exchange (shape (Ns, Np)
)
names
property
List of names of the measurement
rfu_residues
property
Relative fractional uptake per residue.
Returned DataFrame has shape (Nr, Ns*Nt)
, which is multiindex by columns (state, exposure, quantity).
temperature
property
Array of temperature values for each measurement
add_alignment(alignment, first_r_numbers=None)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
alignment
|
FASTA alignments. |
required | |
first_r_numbers
|
default is [1, 1, ...] but specifiy here if alignments do not all start at residue 1 |
None
|
Source code in pyhdx/models.py
905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 |
|
get(name)
Get HDXMeasurement object by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the HDXMeasurement object. |
required |
Returns:
Type | Description |
---|---|
HDXMeasurement
|
The HDXMeasurement object |
Source code in pyhdx/models.py
817 818 819 820 821 822 823 824 825 826 827 828 829 |
|
get_tensors(dtype=None)
Returns a dictionary of tensor variables for fitting HD kinetics.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dtype
|
Optional[dtype]
|
Optional Torch data type. Use torch.float32 for faster fitting of large data sets, possibly at the expense of accuracy. |
None
|
Returns:
Type | Description |
---|---|
dict[str, Tensor]
|
Dictionary with tensors. |
Tensor output and shapes:
- temperature
(Ns, 1, 1)
- X
(Ns, Np, Nr)
- k_int
(Ns, Nr, 1)
- timepoints
(Ns, 1, Nt)
- d_exp
(Ns, Np, Nt)
Source code in pyhdx/models.py
925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 |
|
guess_deltaG(rates_df, correct_c_term=True)
Obtain ΔG initial guesses from apparent H/D exchange rates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rates_df
|
DataFrame
|
Pandas dataframe apparent exchange rates (units s^-1). Column names must correspond to HDX measurement names. |
required |
correct_c_term
|
bool
|
If |
True
|
Returns:
Type | Description |
---|---|
DataFrame
|
ΔG guess values (units J/mol). |
Source code in pyhdx/models.py
883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 |
|
to_file(file_path, include_version=True, include_metadata=True, fmt='csv', **kwargs)
Write the data in this :class:.HDXMeasurementSet
to file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
PathLike
|
File path to create and write to. |
required |
include_version
|
bool
|
Set |
True
|
fmt
|
str
|
Formatting to use, options are 'csv' or 'pprint' |
'csv'
|
include_metadata
|
bool
|
If |
True
|
**kwargs
|
Any
|
Optional additional keyword arguments passed to |
{}
|
Source code in pyhdx/models.py
986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 |
|
HDXTimepoint
Bases: Coverage
Class with subset of peptides corresponding to only one state and exposure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
DataFrame
|
Dataframe with input data. |
required |
**kwargs
|
Any
|
Additional keyword arguments passed to Coverage. |
{}
|
Source code in pyhdx/models.py
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 |
|
d_exp
property
Experimentally measured D-values (corrected)
exposure = self.data['exposure'][0]
instance-attribute
Deuterium exposure time for this HDX timepoint (units seconds)
name
property
Name of this HDX timepoint
Format is
rfu_peptides
property
Relative fractional uptake per peptide
rfu_residues
property
Relative fractional uptake (RFU) per residue.
RFU values are obtained by weighted averaging, weight value is the length of each peptide
rfu_residues_sd
property
Error propagated standard deviations of RFU per residue.
state = self.data['state'][0]
instance-attribute
Protein state label for this HDX timepoint
calc_rfu(residue_rfu)
Calculates RFU per peptide given an array of individual residue scores
Parameters
residue_rfu : :class:~numpy.ndarray
Array of rfu per residue of length prot_len
Returns
:class:~numpy.ndarray
Array of rfu per peptide
Source code in pyhdx/models.py
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
|
propagate_errors(field)
Propagate errors on field
when calculating per-residue weighted average values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field
|
str
|
Data field (column) of errors to propagate. |
required |
Returns:
Type | Description |
---|---|
Series
|
Propagated errors per residue. |
Source code in pyhdx/models.py
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 |
|
weighted_average(field)
Calculate per-residue weighted average of values in data column
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field
|
str
|
Data field (column) to calculated weighted average of |
required |
Returns:
Type | Description |
---|---|
Series
|
THe weighted averaging result |
Source code in pyhdx/models.py
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 |
|
PeptideUptakeModel
Model D-uptake in a single peptide.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sequence
|
list[str]
|
FASTA sequence as list of strings. |
required |
temperature
|
float
|
Temperature of the H/D exchange reaction in Kelvin. |
required |
pH
|
float
|
pH of the H/D exchange reaction. |
required |
Attributes:
Name | Type | Description |
---|---|---|
k_int |
array
|
Array of intrinsic exchanges rates |
Source code in pyhdx/models.py
1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 |
|
eval_analytical(timepoints, k_open, k_close)
Evaluate D-uptake for the given peptide at specified timepoints.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timepoints
|
ndarray
|
Shape |
required |
k_open
|
ndarray
|
Shape |
required |
k_close
|
ndarray
|
Shape |
required |
Returns:
Type | Description |
---|---|
ndarray
|
Shape ( |
Source code in pyhdx/models.py
1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 |
|
gradient_func(t, p, trs_matrix)
staticmethod
calculates dp/dt given a transition state matrix and current populations p(at time t)
:param p: :param t: :param trs_matrix: transition state matrix :return:
Source code in pyhdx/models.py
1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 |
|
contiguous_regions(condition)
Finds contiguous True regions of the boolean array "condition". Returns a 2D array where the first column is the start index of the region and the second column is the end index.
Source code in pyhdx/models.py
1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 |
|