plot
find_wrap(peptides, margin=4, step=5, wrap_limit=200)
Find the minimum wrap value for a given list of intervals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
peptides
|
DataFrame
|
Dataframe with columns 'start' and 'end' representing intervals. |
required |
margin
|
int
|
The margin applied to the wrap value. Defaults to 4. |
4
|
step
|
int
|
The increment step for the wrap value. Defaults to 5. |
5
|
wrap_limit
|
int
|
The maximum allowed wrap value. Defaults to 200. |
200
|
Returns:
| Type | Description |
|---|---|
int
|
The minimum wrap value that does not overlap with any intervals. |
Source code in hdxms_datasets/plot.py
23 24 25 26 27 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 | |
peptide_rectangles(peptides, wrap=None)
Given a DataFrame with 'start' and 'end' columns, each describing a peptide range, this function computes the corresponding rectangle coordinates for visualization.
Typicall used for Altair plotting. The rectangles will be stacked vertically based on the wrap parameter.
Horizontally, each rectangle spans from start - 0.5 to end + 0.5.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
peptides
|
DataFrame
|
DataFrame containing peptide information with 'start' and 'end' columns. |
required |
wrap
|
int | None
|
The number of peptides to stack vertically before wrapping to the next row.
If |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
A DataFrame with columns 'x', 'x2', 'y', and 'y2' representing the rectangle coordinates. |
Source code in hdxms_datasets/plot.py
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 | |
plot_peptides(peptides, value='value', value_sd=None, colormap='viridis', domain=None, bad_color='#8c8c8c', N=256, label=None, width='container', height=350, wrap=None, fill_nan=True)
Create an altair chart visualizing peptides as colored rectangles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
peptides
|
DataFrame
|
DataFrame containing peptide information with 'start', 'end', and |
required |
value
|
str
|
The column name in |
'value'
|
value_sd
|
str | None
|
Optional column name for standard deviation of |
None
|
colormap
|
str | Colormap
|
Colormap to use for coloring the rectangles. Can be a string or a Colormap object. |
'viridis'
|
domain
|
tuple[float | None, float | None] | None
|
Tuple specifying the (min, max) values for the colormap. If |
None
|
bad_color
|
str
|
Color to use for invalid or NaN values. |
'#8c8c8c'
|
N
|
int
|
Number of discrete colors to generate from the colormap. |
256
|
label
|
str | None
|
Label for the color legend. If |
None
|
width
|
str | int
|
Width of the chart. Can be an integer or 'container' for responsive width. |
'container'
|
height
|
str | int
|
Height of the chart in pixels. |
350
|
wrap
|
int | None
|
Number of peptides to stack vertically before wrapping to the next row. If |
None
|
fill_nan
|
bool
|
Whether to fill NaN values in |
True
|
Returns:
| Type | Description |
|---|---|
Chart
|
An Altair Chart object visualizing the peptides. |
Source code in hdxms_datasets/plot.py
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 | |
unique_peptides(df)
Checks if all peptides in the DataFrame are unique. Needs to have columns 'start' and 'end' marking peptide intervals (inclusive).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
DataFrame containing peptide information. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in hdxms_datasets/plot.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |