| 1 |
Analyzing SEC-SAXS data |
| 2 |
************************ |
| 3 |
|
| 4 |
The following examples shows how to carry out analysis on SEC-SAXS data. |
| 5 |
|
| 6 |
Finding and setting buffer and sample regions |
| 7 |
+++++++++++++++++++++++++++++++++++++++++++++++ |
| 8 |
|
| 9 |
.. code-block:: python |
| 10 |
|
| 11 |
import glob |
| 12 |
import os |
| 13 |
import bioxtasraw.RAWAPI as raw |
| 14 |
|
| 15 |
#Load the series |
| 16 |
profile_names = sorted(glob.glob('./series_data/sec_sample_1/profile_001_*.dat')) |
| 17 |
profiles = raw.load_profiles(profile_names) |
| 18 |
series = raw.profiles_to_series(profiles) |
| 19 |
|
| 20 |
#Find an appropriate buffer range for subtraction |
| 21 |
success, start_idx, end_idx = raw.find_buffer_range(series) |
| 22 |
|
| 23 |
#Set the buffer range for the series |
| 24 |
buffer_range = [[start_idx, end_idx]] |
| 25 |
|
| 26 |
(sub_profiles, rg, rger, i0, i0er, vcmw, vcmwer, |
| 27 |
vpmw) = raw.set_buffer_range(series, buffer_range) |
| 28 |
|
| 29 |
#Find an appropriate sample range for subtraction |
| 30 |
success, start_idx, end_idx = raw.find_sample_range(series) |
| 31 |
|
| 32 |
#Set the sample range for the series |
| 33 |
sample_range = [[start_idx, end_idx]] |
| 34 |
|
| 35 |
sub_profile = raw.set_sample_range(series, sample_range) |
| 36 |
|
| 37 |
#Save the analysis done to the series |
| 38 |
if not os.path.exists('./api_results'): |
| 39 |
os.mkdir('./api_results') |
| 40 |
|
| 41 |
raw.save_series(series, 'profile_series.hdf5', './api_results') |
| 42 |
|
| 43 |
|
| 44 |
Once you have the subtracted profile generated by ``set_sample_region`` you |
| 45 |
can carry out analysis on the individual profile as in :ref:`the scattering |
| 46 |
profile analysis tutorial. <profile_analysis>` |
| 47 |
|
| 48 |
|
| 49 |
Applying a linear baseline correction |
| 50 |
+++++++++++++++++++++++++++++++++++++++ |
| 51 |
|
| 52 |
.. code-block:: python |
| 53 |
|
| 54 |
import os |
| 55 |
import bioxtasraw.RAWAPI as raw |
| 56 |
|
| 57 |
#Load series |
| 58 |
xyl_series = raw.load_series(['./series_data/xylanase.hdf5'])[0] |
| 59 |
|
| 60 |
#Set buffer range |
| 61 |
success, start, end = raw.find_buffer_range(xyl_series) |
| 62 |
|
| 63 |
(sub_profiles, rg, rger, i0, i0er, vcmw, vcmwer, |
| 64 |
vpmw) = raw.set_buffer_range(xyl_series, [[start, end]]) |
| 65 |
|
| 66 |
#Validate baseline range |
| 67 |
(lin_valid, lin_valid_results, lin_similarity_results, lin_svd_results, |
| 68 |
lin_intI_results, lin_other_results) = raw.validate_baseline_range( |
| 69 |
xyl_series, [0, 10], [1132, 1142], 'Linear') |
| 70 |
|
| 71 |
#Do baseline correction |
| 72 |
(lin_bl_cor_profiles, lin_rg, lin_rger, lin_i0, lin_i0er, lin_vcmw, lin_vcmwer, |
| 73 |
lin_vpmw, lin_bl_corr, lin_fit_results) = raw.set_baseline_correction( |
| 74 |
xyl_series, [0, 10], [1132, 1142], 'Linear') |
| 75 |
|
| 76 |
#Find an appropriate sample range |
| 77 |
success, start_idx, end_idx = raw.find_sample_range(xyl_series, |
| 78 |
profile_type='baseline') |
| 79 |
|
| 80 |
sample_range = [[start_idx, end_idx]] |
| 81 |
|
| 82 |
sub_profile = raw.set_sample_range(xyl_series, sample_range, |
| 83 |
profile_type='baseline') |
| 84 |
|
| 85 |
#Save the analysis done to the series |
| 86 |
if not os.path.exists('./api_results'): |
| 87 |
os.mkdir('./api_results') |
| 88 |
|
| 89 |
raw.save_series(xyl_series, 'xyl_series.hdf5', './api_results') |
| 90 |
|
| 91 |
Note that setting a buffer range is only necessary if buffer subtraction has |
| 92 |
not already been performed on the series. |
| 93 |
|
| 94 |
Applying an integral baseline correction |
| 95 |
+++++++++++++++++++++++++++++++++++++++++ |
| 96 |
|
| 97 |
.. code-block:: python |
| 98 |
|
| 99 |
import os |
| 100 |
import bioxtasraw.RAWAPI as raw |
| 101 |
|
| 102 |
#Load series |
| 103 |
series = raw.load_series(['./series_data/baseline.hdf5'])[0] |
| 104 |
|
| 105 |
#Find baseline range |
| 106 |
(start_found, end_found, start_range, |
| 107 |
end_range) = raw.find_baseline_range(series) |
| 108 |
|
| 109 |
#Do baseline correction |
| 110 |
(int_bl_cor_profiles, int_rg, int_rger, int_i0, int_i0er, int_vcmw, |
| 111 |
int_vcmwer, int_vpmw, int_bl_corr, |
| 112 |
int_fit_results) = raw.set_baseline_correction(series, start_range, |
| 113 |
end_range, 'Integral') |
| 114 |
|
| 115 |
#Set an appropriate sample range for subtraction |
| 116 |
success, start_idx, end_idx = raw.find_sample_range(series, |
| 117 |
profile_type='baseline') |
| 118 |
|
| 119 |
sample_range = [[start_idx, end_idx]] |
| 120 |
|
| 121 |
sub_profile = raw.set_sample_range(series, sample_range, |
| 122 |
profile_type='baseline') |
| 123 |
|
| 124 |
#Save the analysis done to the series |
| 125 |
if not os.path.exists('./api_results'): |
| 126 |
os.mkdir('./api_results') |
| 127 |
|
| 128 |
raw.save_series(series, 'profile_series_bl.hdf5', './api_results') |
| 129 |
|
| 130 |
Validating buffer and sample regions |
| 131 |
+++++++++++++++++++++++++++++++++++++ |
| 132 |
|
| 133 |
You can validate whatever buffer or sample region you want to set. Note that |
| 134 |
this validation is done as part of the ``find_buffer_region`` and |
| 135 |
``find_sample_region`` functions, so there's no need to do it on regions found |
| 136 |
with those functions. |
| 137 |
|
| 138 |
.. code-block:: python |
| 139 |
|
| 140 |
import bioxtasraw.RAWAPI as raw |
| 141 |
|
| 142 |
#Load series |
| 143 |
xyl_series = raw.load_series(['./series_data/xylanase.hdf5'])[0] |
| 144 |
|
| 145 |
#Validate buffer region |
| 146 |
buffer_range = [[180, 240], [500, 560]] |
| 147 |
|
| 148 |
(valid, similarity_results, svd_results, |
| 149 |
intI_results) = raw.validate_buffer_range(xyl_series, buffer_range) |
| 150 |
|
| 151 |
if not valid: |
| 152 |
success, start, end = raw.find_buffer_range(xyl_series) |
| 153 |
buffer_range = [[start, end]] |
| 154 |
|
| 155 |
(sub_profiles, rg, rger, i0, i0er, vcmw, vcmwer, |
| 156 |
vpmw) = raw.set_buffer_range(xyl_series, [[start, end]]) |
| 157 |
|
| 158 |
#Validate sample region |
| 159 |
sample_range = [[785, 815]] |
| 160 |
|
| 161 |
(valid, similarity_results, param_results, svd_results, |
| 162 |
sn_results) = raw.validate_sample_range(xyl_series, sample_range) |
| 163 |
|
| 164 |
if not valid: |
| 165 |
success, start_idx, end_idx = raw.find_sample_range(xyl_series) |
| 166 |
sample_range = [[start_idx, end_idx]] |
| 167 |
|
| 168 |
sub_profile = raw.set_sample_range(xyl_series, sample_range) |
| 169 |
|
| 170 |
Validating baseline regions |
| 171 |
++++++++++++++++++++++++++++ |
| 172 |
|
| 173 |
You can validate baseline regions. Note that this validation is done as |
| 174 |
part of the ``find_baseline_region`` for an integral baseline, so is not |
| 175 |
necessary in that case. Also, the linear baseline validation is not terribly |
| 176 |
useful at the moment, it almost always returns invalid. |
| 177 |
|
| 178 |
.. code-block:: python |
| 179 |
|
| 180 |
import bioxtasraw.RAWAPI as raw |
| 181 |
|
| 182 |
#Load series |
| 183 |
series = raw.load_series(['./series_data/baseline.hdf5'])[0] |
| 184 |
|
| 185 |
#Validate linear baseline range |
| 186 |
(valid, valid_results, similarity_results, svd_results, intI_results, |
| 187 |
other_results) = raw.validate_baseline_range( series, [0, 10], |
| 188 |
[953, 963], 'Linear') |
| 189 |
|
| 190 |
#Validate integral baseline range |
| 191 |
(valid, valid_results, similarity_results, svd_results, intI_results, |
| 192 |
other_results) = raw.validate_baseline_range(series, [539, 568], |
| 193 |
[817, 846]) |
| 194 |
|
| 195 |
Carrying out SVD, EFA, and REGALS |
| 196 |
++++++++++++++++++++++++++++++++++ |
| 197 |
|
| 198 |
You can carry out SVD, EFA, and REGALS from the API (though without the GUI |
| 199 |
you have to know what the appropriate ranges are for each EFA component as input). |
| 200 |
|
| 201 |
.. code-block:: python |
| 202 |
|
| 203 |
import bioxtasraw.RAWAPI as raw |
| 204 |
|
| 205 |
# Load data |
| 206 |
phehc_series = raw.load_series(['./series_data/phehc_sec.hdf5'])[0] |
| 207 |
|
| 208 |
#Do SVD |
| 209 |
svd_s, svd_U, svd_V = raw.svd(phehc_series) |
| 210 |
|
| 211 |
#Do EFA |
| 212 |
efa_ranges = [[149, 197], [164, 321], [320, 364]] |
| 213 |
|
| 214 |
(efa_profiles, efa_converged, efa_conv_data, |
| 215 |
efa_rotation_data) = raw.efa(phehc_series, efa_ranges) |
| 216 |
|
| 217 |
# Do REGALS |
| 218 |
prof1_settings = { |
| 219 |
'type' : 'simple', |
| 220 |
'lambda' : 0.0, |
| 221 |
'auto_lambda' : True, |
| 222 |
'kwargs' : {}, |
| 223 |
} |
| 224 |
|
| 225 |
conc1_settings = { |
| 226 |
'type' : 'smooth', |
| 227 |
'lambda' : 1.0, |
| 228 |
'auto_lambda' : True, |
| 229 |
'kwargs' : { |
| 230 |
'xmin' : 145, |
| 231 |
'xmax' : 195, |
| 232 |
'Nw' : 50, |
| 233 |
'is_zero_at_xmin' : True, |
| 234 |
'is_zero_at_xmax' : True, |
| 235 |
} |
| 236 |
} |
| 237 |
|
| 238 |
prof2_settings = { |
| 239 |
'type' : 'simple', |
| 240 |
'lambda' : 0.0, |
| 241 |
'auto_lambda' : True, |
| 242 |
'kwargs' : {}, |
| 243 |
} |
| 244 |
|
| 245 |
conc2_settings = { |
| 246 |
'type' : 'smooth', |
| 247 |
'lambda' : 3.0e3, |
| 248 |
'auto_lambda' : False, |
| 249 |
'kwargs' : { |
| 250 |
'xmin' : 160, |
| 251 |
'xmax' : 325, |
| 252 |
'Nw' : 50, |
| 253 |
'is_zero_at_xmin' : True, |
| 254 |
'is_zero_at_xmax' : True, |
| 255 |
} |
| 256 |
} |
| 257 |
|
| 258 |
prof3_settings = { |
| 259 |
'type' : 'simple', |
| 260 |
'lambda' : 0.0, |
| 261 |
'auto_lambda' : True, |
| 262 |
'kwargs' : {}, |
| 263 |
} |
| 264 |
|
| 265 |
conc3_settings = { |
| 266 |
'type' : 'smooth', |
| 267 |
'lambda' : 1.0, |
| 268 |
'auto_lambda' : True, |
| 269 |
'kwargs' : { |
| 270 |
'xmin' : 320, |
| 271 |
'xmax' : 383, |
| 272 |
'Nw' : 50, |
| 273 |
'is_zero_at_xmin' : True, |
| 274 |
'is_zero_at_xmax' : True, |
| 275 |
} |
| 276 |
} |
| 277 |
|
| 278 |
comp_settings = [(prof1_settings, conc1_settings), |
| 279 |
(prof2_settings, conc2_settings), (prof3_settings, conc3_settings)] |
| 280 |
|
| 281 |
(regals_profiles, regals_ifts, concs, reg_concs, mixture, params, |
| 282 |
residual) = raw.regals(phehc_series, comp_settings) |