loader
Module for loading various HDX-MS formats.
get_backend()
Returns the backend used for data handling.
Source code in hdxms_datasets/loader.py
18 19 20 21 22 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 | |
hxms_line_generator(source)
Generate lines from an HXMS file.
Source code in hdxms_datasets/loader.py
102 103 104 105 106 107 108 | |
load_data(data_file)
Load data from the specified file and return a Narwhals DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_file
|
Path
|
Path to the data file. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
A Narwhals DataFrame containing the loaded data. |
Source code in hdxms_datasets/loader.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
load_peptides(peptides, base_dir=Path.cwd(), convert=True, aggregate=None, sort_rows=True, sort_columns=True, drop_null=True)
Load peptides from the data file and return a Narwhals DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
peptides
|
Peptides
|
Peptides object containing metadata and file path. |
required |
base_dir
|
Path
|
Base directory to resolve relative file paths. Defaults to the current working directory. |
cwd()
|
convert
|
bool
|
Whether to convert the data to a standard format. |
True
|
aggregate
|
bool | None
|
Whether to aggregate the data. If None, will aggregate if the data is not already aggregated. |
None
|
sort_rows
|
bool
|
Whether to sort the rows. |
True
|
sort_columns
|
bool
|
Whether to sort the columns in a standard order. |
True
|
drop_null
|
bool
|
Whether to drop columns that are entirely null. |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
A Narwhals DataFrame containing the loaded peptide data. |
Source code in hdxms_datasets/loader.py
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 | |
parse_hxms_lines(lines, read_content=True)
Parse the different sections of an HXMS file.
Returns a dictionary with keys
- "HEADER": list of header lines
- "METADATA": dict of metadata key-value pairs
- "REMARK": dict of remark key-value pairs
- "DATA": Narwhals DataFrame containing the HXMS data (if read_content is True)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lines
|
Iterable[str]
|
An iterable of lines from the HXMS file. |
required |
Returns:
| Type | Description |
|---|---|
HXMSResult
|
A dictionary containing the parsed information. |
Source code in hdxms_datasets/loader.py
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 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 | |
read_csv(source)
Read a CSV file and return a Narwhals DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Path | IO | bytes
|
Source object representing the CSV data. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
A Narwhals DataFrame containing the CSV data. |
Source code in hdxms_datasets/loader.py
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 | |
read_hxms(source)
Read an HXMS file and return a Narwhals DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Path | IO | bytes
|
Source object representing the HXMS data. |
required |
Returns:
| Type | Description |
|---|---|
HXMSResult
|
A Narwhals DataFrame containing the HXMS data. |
Source code in hdxms_datasets/loader.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |