Sc memmap
create_metadata(file_path, shared_dict)
Extract a series of metadata values from AnnData
required to process all files into memmaps.
Note: it assumes var.feature_ids contains the gene symbols for each dataset and corresponds to the same order as the data.X columns.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
PosixPath
|
Path to |
required |
shared_dict
|
Dict[str, Dict[str, object]]
|
Dictionary to store the extracted metadata. |
required |
Returns:
Name | Type | Description |
---|---|---|
None |
None
|
If the file cannot be read or if the |
Source code in bionemo/geneformer/scripts/sc_memmap.py
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 |
|
find_ann_data_files(data_path)
Find all AnnData files with the extension '.h5ad' in the given data path and its subdirectories.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_path
|
str
|
The path to the directory containing the AnnData files. |
required |
Returns:
Type | Description |
---|---|
List[Path]
|
List[str]: A list of file paths to the AnnData files. |
Source code in bionemo/geneformer/scripts/sc_memmap.py
163 164 165 166 167 168 169 170 171 172 |
|
write_data(file_path, obs_cols, metadata, gene_data, gene_data_indices, gene_data_ptr, strict=False)
Writes AnnData
into memmap.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
PosixPath
|
The path to the file. |
required |
obs_cols
|
List[str]
|
A list of columns to extract from each AnnData |
required |
metadata
|
Dict[str, Dict[str, object]]
|
A dictionary containing metadata information on number of elements, shape, and feature names. |
required |
gene_data
|
ndarray
|
The array to store gene data. |
required |
gene_data_indices
|
ndarray
|
The array to store gene data indices. |
required |
gene_data_ptr
|
ndarray
|
The array to store gene data pointers. |
required |
strict
|
bool
|
If True, only extract the columns specified in |
False
|
Returns:
Type | Description |
---|---|
List[DataFrame]
|
List[pd.DataFrame]: The features extracted from the data. |
Source code in bionemo/geneformer/scripts/sc_memmap.py
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 |
|