computer programs\(\def\hfill{\hskip 5em}\def\hfil{\hskip 3em}\def\eqno#1{\hfil {#1}}\)

Journal logoJOURNAL OF
APPLIED
CRYSTALLOGRAPHY
ISSN: 1600-5767

Shape2SAS: a web application to simulate small-angle scattering data and pair distance distributions from user-defined shapes

crossmark logo

aDepartment of Neuroscience, University of Copenhagen, Copenhagen, Denmark, bUniversity of Montana, Missoula, Montana, USA, cNiels Bohr Institute, University of Copenhagen, Copenhagen, Denmark, and dDepartment of Food Science, University of Copenhagen, Copenhagen, Denmark
*Correspondence e-mail: andreas.larsen@sund.ku.dk

Edited by J. Ilavsky, Argonne National Laboratory, USA (Received 24 February 2023; accepted 3 July 2023; online 28 July 2023)

Shape2SAS is a web application that allows researchers and students to build intuition about and understanding of small-angle scattering. It is available at https://somo.chem.utk.edu/shape2sas. The user defines a model of arbitrary shape by combining geometrical subunits, and Shape2SAS then calculates and displays the scattering intensity and the pair distance distribution, as well as a visualization of the user-defined shape. Simulated data with realistic noise are also generated. Here, it is demonstrated how Shape2SAS can calculate and display the different scattering patterns for various geometrical shapes, such as spheres and cylinders. It is also shown how the effect of structure factors can be visualized. Finally, it is indicated how multi-contrast particles can readily be generated, and how the calculated scattering may be used to validate and visualize analytical models generated in analysis software for fitting small-angle scattering data.

1. Introduction

We introduce Shape2SAS, a website for simulating small-angle scattering (SAS) data and pair distance distributions from various shapes. Shape2SAS is readily available as a web application (https://somo.chem.utk.edu/shape2sas) implemented using the GenApp framework (Savelyev & Brookes, 2019[Savelyev, A. & Brookes, E. (2019). Future Generation Comput. Syst. 94, 929-936.]) for constructing graphical user interfaces (GUIs) for scientific software. The user can construct particles of arbitrary shape by combining geometrical subunits, e.g. two spheres and a cylinder to form a dumbbell. The user can thus compare calculated scattering and pair distance distribution from different particle shapes, such as cylinders and spheres, or more elaborate particles shapes, such as dumbbells or spheres coated with smaller spheres. The dimensions and excess scattering-length density of the particle (i.e. contrast between particle and average solvent scattering-length density) can be adjusted to build intuition about how these affect the resulting scattering. The user can also investigate the effects of polydispersity or structure factors.

The website is particularly useful for educators when organizing introductory or advanced courses in SAS data analysis. Due to its nature as a stand-alone web application, the only requirement is a web browser. The program can likewise be used for testing analytical form factors, as demonstrated in this article.

Shape2SAS applies a Monte Carlo based method previously implemented in the program McSim (Hansen, 1990[Hansen, S. (1990). J. Appl. Cryst. 23, 344-346.], 2014[Hansen, S. (2014). J. Appl. Cryst. 47, 1469-1471.]) (see the comparison between Shape2SAS and McSim in Table S1 of the supporting information).

Shape2SAS also outputs simulated data using an empirical error model. The simulated data provide an idea about how exposure time, concentration, contrast and particle size affect the noise in data. Furthermore, the simulated data can be used in tutorials on how to analyze SAS data, e.g. using programs for fitting analytical form factors, such as SasView (https://www.sasview.org/), SASfit (Breßler et al., 2015[Breßler, I., Kohlbrecher, J. & Thünemann, A. F. (2015). J. Appl. Cryst. 48, 1587-1598.]) or WillItFit (Pedersen et al., 2013[Pedersen, M. C., Arleth, L. & Mortensen, K. (2013). J. Appl. Cryst. 46, 1894-1898.]), or programs for ab initio modeling (Franke & Svergun, 2009[Franke, D. & Svergun, D. I. (2009). J. Appl. Cryst. 42, 342-346.]; Grant, 2018[Grant, T. D. (2018). Nat. Methods, 15, 191-193.]).

2. Applied small-angle scattering theory

In this section, we provide the theoretical and computational basis for Shape2SAS, and account for the implementation of this.

2.1. Normalized scattering from identical particles in solution

The normalized SAS from a diluted sample of randomly oriented identical particles can be calculated as a double sum over all scatterers in each particle (Debye, 1915[Debye, P. (1915). Ann. Phys. 351, 809-823.]):

[{I_{{{\rm norm}}}}\left(q \right) = {{\sum \nolimits_{j,k = 1}^N {{\Delta}}{b_j}{{\Delta}}{b_k}\left[{{{{\sin}}\left({q{r_{jk}}} \right)}/{q{r_{jk}}}}\right]} \over {\sum \nolimits_{j,k = 1}^N {{\Delta}}{b_j}{{\Delta}}{b_k}}},]

where Δbj is the excess scattering length of the jth scatterer, rjk is the distance between the jth and kth scatterers, and q is the momentum transfer [[q = 4\pi \sin \left({{\theta}} \right)/\lambda], where 2θ is the scattering angle and λ is the wavelength of the incoming X-rays or the de Broglie wavelength of the incoming neutrons]. N is the number of scatterers in each particle. We assume point scatterers, so the effect of atomic form factors is neglected. The user provides excess scattering-length densities as input, ΔSLDi = Δbi/V, where V is the effective volume of one scatterer. The effective volume is given as the particle volume (Vp) divided by the number of scatterers: V = Vp/N. The point density is kept constant in all subunits, so V is also constant. This normalized scattering is the form factor, P(q), of the particle.

2.2. The pair distance distribution

By binning the scattering pairs after their pair distances, rjk, the double sum can be reduced to a single sum over the number of bins:

[{I_{{{\rm norm}}}}\left(q \right) = {{\sum \nolimits_{i = 1}^{{N_{\rm bins}}} {p_i}\left[{{{{\sin}}\left({q{r_i}} \right)}/{q{r_i}}}\right]} \over {\sum \nolimits_{i = 1}^{{N_{\rm bins}}} {p_i}}},]

where [{r}_{i} = [i-{({1}/{2})}]\,{\rm d}r] and dr is the bin width. The term pi is the number of pairs in each bin, weighted by the product of their excess scattering lengths:

[\eqalign{&{p}_{i} = \textstyle\sum\limits_{j,k = 1}^{N}f\left({r}_{jk}\right)\Delta {b}_{j}\Delta {b}_{k}, \cr&{\rm where}\,\, f\left({r}_{jk}\right) = \cases{1, \quad{\rm if}\, \left(i-1\right) \,{\rm d}r\le {r}_{jk}\,\lt\, i{\rm d}r,\cr 0,\quad {\rm otherwise.}}}]

This is also a double sum but sin(qr)/qr is not evaluated for each distance.

The pair distance distribution p(r) is the continuous limit of [p = \{ {p_1},{p_2}, \ldots, {p_{{N_{{{\rm bins}}}}}}\}], as Nbins → ∞ and N → ∞. In this limit, the contributions from the self terms (j = k) are negligible. Therefore, the self terms are excluded from the sums in Shape2SAS, and p(0) = 0 is added.

The largest distance in the particle, Dmax, is given as output, along with the radius of gyration (Glatter, 1977[Glatter, O. (1977). J. Appl. Cryst. 10, 415-421.]; Guinier & Fournet, 1955[Guinier, A. & Fournet, G. (1955). Small-Angle Scattering of X-rays. New York: John Wiley and Sons.]):

[R_{{\rm g}}^2 = {1 \over 2}{{ \int \nolimits_0^{{D_{{{\rm max}}}}} {r^2}p\left(r \right)\,{\rm d}r} \over {\int \nolimits_0^{{D_{{{\rm max}}}}} p\left(r \right)\,{\rm d}r}}.]

The output p(r) is normalized, so the maximum is unity.

2.3. Polydispersity

Polydispersity implies a distribution of sizes of the particles (Pauw et al., 2013[Pauw, B. R., Pedersen, J. S., Tardif, S., Takata, M. & Iversen, B. B. (2013). J. Appl. Cryst. 46, 365-371.]). Shape2SAS allows for inclusion of a simple Gaussian size distribution. The size distribution is implemented by introducing a size-scaling parameter, s, which scales all distances in the user-defined shape (rsr). The parameter s is normally distributed, with a mean of unity (μs = 1) and standard deviation (σs) set by the user.

[{p}_{\rm poly}\left(r,{\sigma }_{s}\right) = {{{\int }_{0}^{\infty }{p}_{s}\left(r\right)\exp\left\{{(-{{1}/{2})}{\left[{{(s-1)}/{{\sigma }_{s}}}\right]}^{2}}\right\}{v}_{s}^{2}\,{\rm d}s}\over{{\int }_{0}^{\infty }\exp\left\{{(-{{1}/{2})}{\left[{{(s-1)}/{{\sigma }_{s}}}\right]}^{2}}\right\}{v}_{s}^{2}\,{\rm d}s}},]

where ps(r) is the pair distance distribution after scaling all distances with s and vs = s3 is a relative (unitless) volume, which is included to account for the fact that the scattering from a particle is proportional to the square of the molecular volume. The relative volume is an approximation and is only exact for spheres. The integrals are evaluated numerically with upper and lower limits of 1 ± 3σs

While this is a simplification of the many ways in which a sample can exhibit polydispersity, the implementation is simple and efficient, and allows users and students to explore the consequences of polydispersity in SAS data.

2.4. Structure factors

Interparticle interactions can be expressed in the form of structure factors, and the normalized scattering intensity can be expressed as a product of the form factor and the structure factor (Breßler et al., 2015[Breßler, I., Kohlbrecher, J. & Thünemann, A. F. (2015). J. Appl. Cryst. 48, 1587-1598.]):

[{I_{{{\rm norm}}}}\left(q \right) = P\left(q \right)S\left(q \right).]

So far, two structure factors are implemented in Shape2SAS: a hard-sphere structure factor (Kinning & Thomas, 1984[Kinning, D. J. & Thomas, E. L. (1984). Macromolecules, 17, 1712-1718.]), describing interparticle repulsion, and a 2D fractal structure factor, describing particle aggregation (Larsen et al., 2020[Larsen, A. H., Pedersen, J. S. & Arleth, L. (2020). J. Appl. Cryst. 53, 991-1005.]). The decoupling approximation is also applied to account for non-spherical or polydisperse particles (Kotlarchyk & Chen, 1983[Kotlarchyk, M. & Chen, S. H. (1983). J. Chem. Phys. 79, 2461-2469.]; Larsen et al., 2020[Larsen, A. H., Pedersen, J. S. & Arleth, L. (2020). J. Appl. Cryst. 53, 991-1005.]). Although such interparticle interactions would affect the effective pair distance distribution, the program only applies the structure factor on the calculated scattering intensity. That is, if a structure factor is opted for, the output p(r) is from non-interacting particles, whereas I(q) is from a sample of interacting particles. The p(r) of the interacting particles can e.g. be generated in BayesApp (Hansen, 2012[Hansen, S. (2012). J. Appl. Cryst. 45, 566-567.]), which is likewise available as a web application in GenApp.

2.5. Interface roughness

A particle can be modeled by combining geometrical subunits. If the subunits have different contrasts, there may be discrepancies between the sharp boundaries between subunits of the model and the softer and more fluent boundaries between components in an actual particle. The interface roughness can be modeled by including a surface roughness factor (Als-Nielsen & McMorrow, 2011[Als-Nielsen, J. & McMorrow, D. (2011). Elements of Modern X-ray Physics. Chichester: Wiley.]), which effectively smears the interfaces:

[{I_{{{\rm norm}}}}\left(q \right) = P\left(q \right)S(q)\exp\left[{{-\textstyle{{1}\over{2}}}{{({q{\sigma _{{{\rm rough}}}}})}^2}}\right],]

where σrough is a smearing parameter. In Shape2SAS, surface roughness only affects Inorm(q), not p(r). Such terms have been applied to fit scattering from liquid–vapor interfaces (Als-Nielsen, 1986[Als-Nielsen, J. (1986). Physica A, 140, 376-389.]), microemulsions (Skar-Gislinge & Arleth, 2011[Skar-Gislinge, N. & Arleth, L. (2011). Phys. Chem. Chem. Phys. 13, 3161-3170.]; Foster et al., 2008[Foster, T., Sottmann, T., Schweins, R. & Strey, R. (2008). J. Chem. Phys. 128, 064902.]) and protein–lipid nanodiscs (Skar-Gislinge & Arleth, 2011[Skar-Gislinge, N. & Arleth, L. (2011). Phys. Chem. Chem. Phys. 13, 3161-3170.]; Barclay et al., 2022[Barclay, A., Tidemand Johansen, N., Tidemand, F. G., Arleth, L. & Pedersen, M. C. (2022). Acta Cryst. D78, 483-493.]).

2.6. Simulation of data with an empirical noise model

Besides the pair distance distribution and the normalized scattering, Shape2SAS also outputs simulated data, Isim(q). First, the forward scattering is calculated, so that it scales with particle volume, Vp, and volume fraction (concentration of the sample), η:

[I(0) = \eta {V_{\rm{p}}}{ \textstyle\sum\limits_{i = 1}^{{N_{\rm bins}}} {p_i}}.]

The last factor depends on the contrast, and if all subunits have the same contrast then [\textstyle\sum_i {p_i} = {{\Delta \rm SL}}{{{\rm D}}^2}]. The scaled scattering is given as I(q) = I(0)Inorm(q).

The errors, σsim(q), are estimated using an empirical model based on small-angle X-ray scattering (SAXS) data (Sedlak et al., 2017[Sedlak, S. M., Bruetzel, L. K. & Lipfert, J. (2017). J. Appl. Cryst. 50, 621-630.]), using the scaled scattering, I(q), and the relative exposure time as input (Appendix A[link]). When using the default parameters, the errors resemble those from a typical synchrotron SAXS experiment. To simulate laboratory-source data, the exposure time should be reduced, e.g. by an order of magnitude (Sedlak et al., 2017[Sedlak, S. M., Bruetzel, L. K. & Lipfert, J. (2017). J. Appl. Cryst. 50, 621-630.]). Future efforts are needed to simulate realistic small-angle neutron scattering (SANS) errors (see Discussion[link]). The simulated data, Isim(q), are sampled stochastically from normal distributions with means I(q) and standard deviations σsim(q).

3. Implementation

3.1. Architecture

The program is designed for ease of use and ease of maintenance. Input parameters are provided via an online GUI (Fig. 1[link]). Inputs are read by a Python wrapper script. The wrapper calls Python functions that perform the calculations and return output files, plots and values to the wrapper. Finally, the wrapper returns the output to the GUI, which displays them for the user.

[Figure 1]
Figure 1
Simulating scattering from a sphere (red) and a cylinder (blue) using Shape2SAS. (a) GUI input parameters. (b) GUI output parameters. (c) Pair distance distributions. (d) Calculated normalized scattering. (e) Simulated scattering intensities with noise. (f) 2D projections of the models. (g) 3D models rendered in PyMOL (https://www.pymol.org).

3.2. Description of core functions

A core element of Shape2SAS is the Python function that generates points from a given subunit. First, the limits of the geometric subunit are defined in either Cartesian, polar or spherical coordinates. Then, random uniformly distributed points are generated in the volume defined by the subunit. Lastly, if selected, the points are shifted to a new center of mass. The volumes of the subunits are calculated, and the number of points inserted in each subunit is adjusted, so that the point density is constant (see Applied small-angle scattering theory[link]). The total number of points in the model (composed of one or more subunits) is N = 3000 by default, which provides a rapid result. For higher precision, N can be increased. The computational time goes as N2. For N = 3000 and two models, the results and plots are available within 6 s, whereas e.g. for N = 9000 and two models, the results and plots are available within 14 s. The SAS intensity calculated from the same particle will vary stochastically, with larger differences at higher values of q. By increasing N, the differences are decreased; depending on the q range of interest, N should be adjusted to balance computational time against precision. With 5000 points, the calculated intensity for a 50 Å sphere is precisely reproduced up to approximately q = 0.2 Å−1 (Fig. S1 of the supporting information). In the case of overlap between subunits, the points from the subunits furthest down the list of subunits are removed, e.g. if the user chooses a 30 Å sphere with ΔSLD = −1 as the first subunit and a 50 Å sphere with ΔSLD = 1 as the second subunit, the resulting particle will be a core–shell particle with a 30 Å core with ΔSLD = −1 and a shell with thickness of 20 Å and ΔSLD = 1 (examples in Fig. S2). In the overlap region, only the points from the first subunit remain. Exclusion of points from overlapping subunits can be exploited in multi-contrast situations (see Example 3[link]).

Another core element is the calculation of all distances in a model. This step is time and memory consuming, and one of the computational bottlenecks of the program. However, using the NumPy (Harris et al., 2020[Harris, C. R., Millman, K. J., van der Walt, S. J., Gommers, R., Virtanen, P., Cournapeau, D., Wieser, E., Taylor, J., Berg, S., Smith, N. J., Kern, R., Picus, M., Hoyer, S., van Kerkwijk, M. H., Brett, M., Haldane, A., del Río, J. F., Wiebe, M., Peterson, P., Gérard-Marchant, P., Sheppard, K., Reddy, T., Weckesser, W., Abbasi, H., Gohlke, C. & Oliphant, T. E. (2020). Nature, 585, 357-362.]) function meshgrid(), all distances between 3000 points are calculated in less than a second on the GenApp server. Another computational bottleneck is the calculation of p(r). This is carried out using the NumPy function histogram(). When polydispersity is included, several histograms are calculated, and in that case Shape2SAS uses the histogram1d() function (https://github.com/astrofrog/fast-histogram), which is faster than NumPy's histogram(). A polydisperse p(r) is thus calculated in a few seconds.

3.3. User interface

A key goal of the project is accessibility and ease of use. Therefore, the program is implemented as a web application, meaning that no installation is required. This is optimal for use in courses and tutorials. The program is part of the GenApp (Savelyev & Brookes, 2019[Savelyev, A. & Brookes, E. (2019). Future Generation Comput. Syst. 94, 929-936.]) vision for making SAS software available for everyone.

The user builds up a model of a predefined set of geometric subunits, currently including sphere, triaxial ellipsoid, cylinder, disc, cube, cuboid, hollow sphere, hollow cube, cylindrical ring and discoidal ring. The geometrical parameters of the subunits can then be changed from the default values, along with their contrast and center of mass. A model consists of the collected points in the volume spanned by the subunits. By default, points are deleted from overlapping regions, but this is optional as mentioned above. If a structure factor is selected, the scattering contribution from the structure factor will be displayed along with the total scattering.

The user can choose to calculate p(r) and I(q) from additional models (up to four), and the procedure is the same as for the first model. The p(r) and I(q) from the models are plotted together in the GUI, and can thus be directly compared without having to plot the data in third-party software. The simulated data can be scaled in the plot for easy visual inspection.

All output data [p(r), Inorm(q) and Isim(q)], as well as plots and a 3D model for visualization (in PDB format), can be downloaded from the web interface for further analysis, plotting etc.

3.4. Documentation and validation

All menus and input boxes in the GUI are described with help text, which is shown by hovering the mouse over the elements. The source code is documented with extensive comments in the code, including documentation of all functions. Central references are provided directly in the GUI. Each model is visualized as a 3D point model using a Jmol (https://www.jmol.org/) plugin and as 2D projections. Shape2SAS models and structure factors have been tested against analytical models using SasView (https://www.sasview.org).

Source code is available on GitHub (https://github.com/ehb54/GenApp-Shape2SAS) under the GNU General Public License v3.0.

4. Examples of use

These examples are designed to be relevant in the context of research as well as research-based teaching. The first example showcases how Shape2SAS can be used for generating intuition about SAS from different shapes, and the second example demonstrates the effect of inter-particle interactions. The last example demonstrates how more complex particles can be built and how Shape2SAS can be utilized to test analytical form factors.

4.1. Example 1: comparing scattering from particles of different shape

Shape2SAS can be used to quickly calculate and compare p(r) and I(q) from particles with various shapes. One example is the scattering from a sphere with a radius of 50 Å, and a cylinder with a radius of 20 Å and a length of 400 Å (Fig. 1[link]). Such an example could help a student build intuition about the scattering and pair distance distribution functions for e.g. spherical, elongated or hollow bodies. Moreover, Rg and Dmax are calculated and displayed in the GUI for quick comparison.

4.2. Example 2: hard-sphere structure factor

Shape2SAS can add inter-particle interactions to the scattering using built-in structure factors. One example is shown in Fig. 2[link], where the scattering from a sample of ellipsoids of revolution (minor axis 50 Å and major axis 100 Å) was calculated with and without interparticle interaction, described by the hard-sphere structure factor and the decoupling approximation, with a hard-sphere radius of 70 Å and a volume fraction of 0.2. Such an exercise could help students or researchers to understand the effect of structure factors and recognize interparticle interactions in measured SAS data.

[Figure 2]
Figure 2
Scattering intensity from ellipsoids with and without interparticle repulsion. (a) Pair distance distributions from two instances of a prolate ellipsoid of revolution, without interparticle repulsion. Inset: 2D projections of the ellipsoid along the minor and major axes. (b) Normalized scattering intensity from the ellipsoids with and without interparticle repulsion as described by a hard-sphere structure factor. (c) Simulated scattering, with noise.

4.3. Example 3: validating analytical form factor

Shape2SAS can be used when developing analytical form factors. By generating the same shape in Shape2SAS as that of the analytical model, the simulated data from Shape2SAS can be fitted. In this example, a core–shell cylinder was simulated (core radius 20 Å, core length 360 Å, shell thickness 20 Å, core contrast −1 and shell contrast +1). The example also showcases how multi-contrast particles can be generated in two ways in Shape2SAS. In the first approach, the core–shell cylinder is generated by combining non-overlapping subunits: a cylinder core, a hollow cylindrical shell and two small cylinders with shifted center of mass as end caps [Fig. 3[link](a)]. In the second approach, a large shell cylinder and a smaller core cylinder are combined, and points from the shell cylinder are removed from the overlapping region [Fig. 3[link](a)]. Both result in the same model, p(r) and I(q) [Figs. 3[link](b) and 3[link](c)]. If there is overlap, and exclusion of overlapping points is not opted for, then the contrast in the overlap region will effectively be the sum of contrasts of the overlapping subunits.

[Figure 3]
Figure 3
Core–shell cylinder data, simulated in Shape2SAS and fitted with an analytical model. (a) Core–shell cylinder input, without use of exclusion and with use of exclusion. (b) Pair distance distribution from Shape2SAS. (c) Normalized SAS intensity. (d) Simulated data fitted with the analytical model core_shell_cylinder from SasView. Inset: 2D projections of the core–shell cylinder.

The simulated data were fitted with the analytical model core_shell_cylinder from SasView (https://www.sasview.org/sasmodels/model/core_shell_cylinder.html). The data were well described by the model [Fig. 3[link](d)] and the model parameters were refined to values consistent with the input parameters (core radius 20.10 ± 0.07 Å, core length 363 ± 2 Å, shell thickness 20.1 ± 0.1 Å and shell contrast +0.97 ± 0.01). The errors are standard deviations. The core contrast was fixed at −1, since the combination of fitting core contrast and shell contrasts, and then scaling, gave high correlation between the parameters.

The demonstrated procedure can be valuable for testing new and more complex analytical models (Jakubauskas et al., 2019[Jakubauskas, D., Kowalewska, Ł., Sokolova, A. V., Garvey, C. J., Mortensen, K., Jensen, P. E. & Kirkensgaard, J. J. K. (2019). Sci. Rep. 9, 19405. ]), and for visualizing them as bead models.

This workflow is helpful when coding analytical models for SAS from particles in solution. While analytical models are often ideal for implementation in a model-refinement framework (such as SasView), Shape2SAS offers a simple, graphical and intuitive manner for testing the implementation and its accuracy – in real space.

5. Discussion

Shape2SAS is useful for demonstrations and tutorials, which has been showcased by three examples. Example 1[link] compared the SAS from a sphere with the SAS from a cylinder; Example 2[link] demonstrated the effect of interparticle repulsion via a hard-sphere structure factor; and Example 3[link] showcased how more advanced shapes can be built, with various excess scattering-length densities, and how Shape2SAS can be used to test analytical form factors.

When carrying out analysis of the simulated data, discrepancies between input parameters and refined parameters may occur from the stochastic nature of Shape2SAS and the limited number of simulated points [Fig. 3[link](d)]. Moreover, if polydispersity is fitted, this is probably implemented differently in analytical models and may result in discrepancies.

Shape2SAS does not distinguish between SAXS and SANS. To make the distinction, the scattering-length densities should be provided in real units, reflecting either electron density or neutron scattering length density. Moreover, the empirical error model was derived from SAXS data. In SANS, the incoherent scattering should be considered along with resolution effects (Pedersen et al., 1990[Pedersen, J. S., Posselt, D. & Mortensen, K. (1990). J. Appl. Cryst. 23, 321-333.]). Furthermore, SANS data are often collected in several settings and subsequently merged (Pedersen, 2002a[Pedersen, J. S. (2002a). Neutrons, X-rays and Light: Scattering Methods Applied to Soft Condensed Matter, edited by P. Lindner & Th. Zemb, pp. 127-144. Amsterdam: Elsevier.]), which should be reflected in the error model.

Other programs exist that can calculate the theoretical scattering from various shapes using form factors, including SASfit (Kohlbrecher & Breßler, 2022[Kohlbrecher, J. & Breßler, I. (2022). J. Appl. Cryst. 55, 1677-1688.]), Irena (Ilavsky & Jemian, 2009[Ilavsky, J. & Jemian, P. R. (2009). J. Appl. Cryst. 42, 347-353.]) and SasView (https://www.sasview.org/). These programs can also be used to build intuition about the scattering from particles of various shapes, and the effect of changing model parameters or adding structure factors. Shape2SAS is complementary to these programs: (i) by being available as a web application; (ii) by performing fast comparison of scattering and pair distance distributions from particles of various shapes; (iii) by automatically visualizing the particles; (iv) by generating simulated data with an empirical error model, which can be used as a virtual experiment for tutorials and to build intuition about some of the sources of noise in a SAS experiment; and (v) by being able to calculate scattering from particles that cannot be described by an analytical form factor.

Shape2SAS is one among many programs for making virtual experiments (Lefmann et al., 2008[Lefmann, K., Willendrup, P. K., Udby, L., Lebech, B., Mortensen, K., Birk, J. O., Klenø, K., Knudsen, E., Christiansen, P., Saroun, J., Kulda, J., Filges, U., Konnecke, M., Tregenna-Piggott, P., Peters, J., Lieutenant, K., Zsigmond, G., Bentley, P. & Farhi, E. (2008). J. Neutron Res. 16, 97-111.]), some of which can also generate 2D X-ray (Bergbäck Knudsen et al., 2012[Bergbäck Knudsen, E., Prodi, A., Baltser, J., Thomsen, M., Kjær Willendrup, P., Sanchez del Rio, M., Ferrero, C., Farhi, E., Haldrup, K., Vickery, A., Feidenhans'l, R., Mortensen, K., Meedom Nielsen, M., Friis Poulsen, H., Schmidt, S. & Lefmann, K. (2013). J. Appl. Cryst. 46, 679-696. ]; Franke et al., 2020[Franke, D., Hajizadeh, N. R. & Svergun, D. I. (2020). J. Appl. Cryst. 53, 536-539.]) or neutron (Willendrup & Lefmann, 2021[Willendrup, P. K. & Lefmann, K. (2021). J. Neutron Res. 23, 7-27.]) scattering data. Shape2SAS focuses on the data-analysis step, after reduction from 2D to 1D data, and after buffer subtraction. Common for such virtual-experiment software is the goal of preparing the user for best use of valuable beam time, and for helping the user to better understand and analyze the measured data. Shape2SAS excels in accessibility, meaning that virtual data can be generated in seconds, with no installation requirements.

In principle, the Shape2SAS input parameters could be transformed into variable parameters, and by addition of a scaling and a constant background, such a modified program could be used for fitting. It has previously been shown that Monte Carlo bead modeling approaches are useful in SAS analysis (Pedersen, 2002b[Pedersen, J. S. (2002b). Neutrons, X-rays and Light: Scattering Methods Applied to Soft Condensed Matter, edited by P. Lindner & Th. Zemb, pp. 381-390. Amsterdam: Elsevier.]), especially for generating complicated models that are difficult to describe through analytical form factors [e.g. perforated vesicles (Pedersen et al., 2012[Pedersen, J. S., Oliveira, C. L. P., Hübschmann, H. B., Arleth, L., Manniche, S., Kirkby, N. & Nielsen, H. M. (2012). Biophys. J. 102, 2372-2380.]) or protein–lipid complexes (Pedersen et al., 2022[Pedersen, M. C., Johansen, N. T., Roche, J., Järvå, M., Törnroth-Horsefield, S. & Arleth, L. (2022). bioRxiv, 2022.10.28.512841.])]. However, other programs applying the same principles have been developed with fitting in mind, including CDEF (Deumer et al., 2022[Deumer, J., Pauw, B. R., Marguet, S., Skroblin, D., Taché, O., Krumrey, M. & Gollwitzer, C. (2022). J. Appl. Cryst. 55, 993-1001.]) and SPONGE (https://github.com/bamresearch/sponge), and we recommend use of these for fitting. CDEF applies the same principle of binning scattering pairs as Shape2SAS, whereas SPONGE applies the Debye formula directly, making it more accurate at the cost of longer computational times. When fitting actual data, we also encourage parametrizing the model to reflect physical properties rather than geometrical, to be able to better constrain and validate the refined parameters, e.g. with biophysical assays [see e.g. Skar-Gislinge & Arleth (2011[Skar-Gislinge, N. & Arleth, L. (2011). Phys. Chem. Chem. Phys. 13, 3161-3170.]) and Larsen et al. (2018[Larsen, A. H., Arleth, L. & Hansen, S. (2018). J. Appl. Cryst. 51, 1151-1161.])]. This is not possible in Shape2SAS and would typically have to be adjusted from case to case, which is easier without a GUI. Shape2SAS may, however, be downloaded, and functions reused by developers, to accommodate specific needs.

In summary, Shape2SAS makes SAS theory intuitive, visual, playful and accessible for both new and experienced users.

APPENDIX A

Empirical error model

The errors were generated following the previously outlined protocol (Sedlak et al., 2017[Sedlak, S. M., Bruetzel, L. K. & Lipfert, J. (2017). J. Appl. Cryst. 50, 621-630.]):

(1) Compute a theoretical SAS profile, I(q), as described in the main text.

(2) Scale I(q). Scaling is done such that the scattering from a 50 Å sphere with ΔSLD of unity (default parameters) has a forward scattering of approximately unity.

(3) Multiply the scaled I(q) by the relative exposure time (GUI input) to get Is(q).

(4) Calculate the variance using c = 0.85 and [{q}_{\rm arb} = 0.3\, {\AA }^{-1}], which define the constant scattering intensity of the buffer, Ibuf(q) = cIs(qarb) (Sedlak et al., 2017[Sedlak, S. M., Bruetzel, L. K. & Lipfert, J. (2017). J. Appl. Cryst. 50, 621-630.]):

[{\sigma ^2} = {{{I_s}(q)} \over {N(q)}} + {{2c{I_s}({q_{{{\rm arb}}}})} \over {1 - c}}.]

In the original error model (Sedlak et al., 2017[Sedlak, S. M., Bruetzel, L. K. & Lipfert, J. (2017). J. Appl. Cryst. 50, 621-630.]), the number of pixels per q bin, N(q), was approximated by kq. This is, however, only valid up to a certain q value, qt, which depends on detector size and geometry. Therefore, we use a modified empirical expression for N(q) that better describes the number of pixels per q bin at higher values of q:

[N(q) = \cases{kq,\quad {\rm if}\, q\le {q}_{t},\cr k{q}_{t}\exp\left\{{(-{{1}/{2}})\left[{{(q-{q}_{t})}/{b}}\right]}^{a}\right\} ,\quad {\rm otherwise}.}]

Values of k = 4500, [{q}_{t} = 1.4\,{ \AA }^{-1}], a = 3 and b = 0.6 Å−1 were used in Shape2SAS to approximate a synchrotron SAXS setup with centered beam center on a PILATUS 2M detector (Fig. S3).

Supporting information


Acknowledgements

The authors thank Steffen M. Sedlak and Jan Lipfert for support in expanding the error model to high-q data (Appendix A[link]). The authors acknowledge Steen Hansen for valuable discussions and inspiration, and the students at various courses on scattering techniques at the University of Copenhagen, who have tested the program.

Funding information

This work used the Extreme Science and Engineering Discovery Environment (XSEDE) (Towns et al., 2014[Towns, J., Cockerill, T., Dahan, M., Foster, I., Gaither, K., Grimshaw, A., Hazlewood, V., Lathrop, S., Lifka, D., Peterson, G. D., Roskies, R., Scott, J. & Wilkins-Diehr, N. (2014). Comput. Sci. Eng. 16, 62-74.]), which is supported by National Science Foundation (NSF) grant No. ACI-1548562 and utilized Jetstream2 (Hancock et al., 2021[Hancock, D. Y., Fischer, J., Lowe, J. M., Snapp-Childs, W., Pierce, M., Marru, S., Coulter, J. E., Vaughn, M., Beck, B., Merchant, N., Skidmore, E. & Jacobs, G. (2021). Proceedings of the Practice and Experience in Advanced Research Computing (PEARC '21), pp. 1-8. New York: Association for Computing Machinery.]) at Indiana University through allocation TG-MCB17057 to EB. This work benefited from the CCP-SAS (Perkins et al., 2016[Perkins, S. J., Wright, D. W., Zhang, H., Brookes, E. H., Chen, J., Irving, T. C., Krueger, S., Barlow, D. J., Edler, K. J., Scott, D. J., Terrill, N. J., King, S. M., Butler, P. D. & Curtis, J. E. (2016). J. Appl. Cryst. 49, 1861-1875.]) software developed through a joint Engineering and Physical Sciences Research Council (EPSRC) (EP/K039121/1) and NSF (CHE-1265821) grant. AHL was funded by the Lundbeck Foundation grant R347-2020-2339. EB was funded by the National Institutes of Health, National Institute of General Medical Sciences grant GM120600 and NSF grant 1912444.

References

First citationAls-Nielsen, J. (1986). Physica A, 140, 376–389.  CrossRef Web of Science Google Scholar
First citationAls-Nielsen, J. & McMorrow, D. (2011). Elements of Modern X-ray Physics. Chichester: Wiley.  Google Scholar
First citationBarclay, A., Tidemand Johansen, N., Tidemand, F. G., Arleth, L. & Pedersen, M. C. (2022). Acta Cryst. D78, 483–493.  Google Scholar
First citationBergbäck Knudsen, E., Prodi, A., Baltser, J., Thomsen, M., Kjær Willendrup, P., Sanchez del Rio, M., Ferrero, C., Farhi, E., Haldrup, K., Vickery, A., Feidenhans'l, R., Mortensen, K., Meedom Nielsen, M., Friis Poulsen, H., Schmidt, S. & Lefmann, K. (2013). J. Appl. Cryst. 46, 679–696.   CrossRef IUCr Journals Google Scholar
First citationBreßler, I., Kohlbrecher, J. & Thünemann, A. F. (2015). J. Appl. Cryst. 48, 1587–1598.  Web of Science CrossRef IUCr Journals Google Scholar
First citationDebye, P. (1915). Ann. Phys. 351, 809–823.  CrossRef Google Scholar
First citationDeumer, J., Pauw, B. R., Marguet, S., Skroblin, D., Taché, O., Krumrey, M. & Gollwitzer, C. (2022). J. Appl. Cryst. 55, 993–1001.  Google Scholar
First citationFoster, T., Sottmann, T., Schweins, R. & Strey, R. (2008). J. Chem. Phys. 128, 064902.  Google Scholar
First citationFranke, D., Hajizadeh, N. R. & Svergun, D. I. (2020). J. Appl. Cryst. 53, 536–539.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationFranke, D. & Svergun, D. I. (2009). J. Appl. Cryst. 42, 342–346.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationGlatter, O. (1977). J. Appl. Cryst. 10, 415–421.  CrossRef IUCr Journals Web of Science Google Scholar
First citationGrant, T. D. (2018). Nat. Methods, 15, 191–193.  Web of Science CrossRef CAS PubMed Google Scholar
First citationGuinier, A. & Fournet, G. (1955). Small-Angle Scattering of X-rays. New York: John Wiley and Sons.  Google Scholar
First citationHancock, D. Y., Fischer, J., Lowe, J. M., Snapp-Childs, W., Pierce, M., Marru, S., Coulter, J. E., Vaughn, M., Beck, B., Merchant, N., Skidmore, E. & Jacobs, G. (2021). Proceedings of the Practice and Experience in Advanced Research Computing (PEARC '21), pp. 1–8. New York: Association for Computing Machinery.  Google Scholar
First citationHansen, S. (1990). J. Appl. Cryst. 23, 344–346.  CrossRef Web of Science IUCr Journals Google Scholar
First citationHansen, S. (2012). J. Appl. Cryst. 45, 566–567.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationHansen, S. (2014). J. Appl. Cryst. 47, 1469–1471.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationHarris, C. R., Millman, K. J., van der Walt, S. J., Gommers, R., Virtanen, P., Cournapeau, D., Wieser, E., Taylor, J., Berg, S., Smith, N. J., Kern, R., Picus, M., Hoyer, S., van Kerkwijk, M. H., Brett, M., Haldane, A., del Río, J. F., Wiebe, M., Peterson, P., Gérard-Marchant, P., Sheppard, K., Reddy, T., Weckesser, W., Abbasi, H., Gohlke, C. & Oliphant, T. E. (2020). Nature, 585, 357–362.  Web of Science CrossRef CAS PubMed Google Scholar
First citationIlavsky, J. & Jemian, P. R. (2009). J. Appl. Cryst. 42, 347–353.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationJakubauskas, D., Kowalewska, Ł., Sokolova, A. V., Garvey, C. J., Mortensen, K., Jensen, P. E. & Kirkensgaard, J. J. K. (2019). Sci. Rep. 9, 19405.   Google Scholar
First citationKinning, D. J. & Thomas, E. L. (1984). Macromolecules, 17, 1712–1718.  CrossRef CAS Web of Science Google Scholar
First citationKohlbrecher, J. & Breßler, I. (2022). J. Appl. Cryst. 55, 1677–1688.  CrossRef IUCr Journals Google Scholar
First citationKotlarchyk, M. & Chen, S. H. (1983). J. Chem. Phys. 79, 2461–2469.  CrossRef CAS Web of Science Google Scholar
First citationLarsen, A. H., Arleth, L. & Hansen, S. (2018). J. Appl. Cryst. 51, 1151–1161.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationLarsen, A. H., Pedersen, J. S. & Arleth, L. (2020). J. Appl. Cryst. 53, 991–1005.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationLefmann, K., Willendrup, P. K., Udby, L., Lebech, B., Mortensen, K., Birk, J. O., Klenø, K., Knudsen, E., Christiansen, P., Saroun, J., Kulda, J., Filges, U., Konnecke, M., Tregenna-Piggott, P., Peters, J., Lieutenant, K., Zsigmond, G., Bentley, P. & Farhi, E. (2008). J. Neutron Res. 16, 97–111.  CrossRef CAS Google Scholar
First citationPauw, B. R., Pedersen, J. S., Tardif, S., Takata, M. & Iversen, B. B. (2013). J. Appl. Cryst. 46, 365–371.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationPedersen, J. S. (2002a). Neutrons, X-rays and Light: Scattering Methods Applied to Soft Condensed Matter, edited by P. Lindner & Th. Zemb, pp. 127–144. Amsterdam: Elsevier.  Google Scholar
First citationPedersen, J. S. (2002b). Neutrons, X-rays and Light: Scattering Methods Applied to Soft Condensed Matter, edited by P. Lindner & Th. Zemb, pp. 381–390. Amsterdam: Elsevier.  Google Scholar
First citationPedersen, J. S., Oliveira, C. L. P., Hübschmann, H. B., Arleth, L., Manniche, S., Kirkby, N. & Nielsen, H. M. (2012). Biophys. J. 102, 2372–2380.  Web of Science CrossRef CAS PubMed Google Scholar
First citationPedersen, J. S., Posselt, D. & Mortensen, K. (1990). J. Appl. Cryst. 23, 321–333.  CrossRef Web of Science IUCr Journals Google Scholar
First citationPedersen, M. C., Arleth, L. & Mortensen, K. (2013). J. Appl. Cryst. 46, 1894–1898.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationPedersen, M. C., Johansen, N. T., Roche, J., Järvå, M., Törnroth-Horsefield, S. & Arleth, L. (2022). bioRxiv, 2022.10.28.512841.  Google Scholar
First citationPerkins, S. J., Wright, D. W., Zhang, H., Brookes, E. H., Chen, J., Irving, T. C., Krueger, S., Barlow, D. J., Edler, K. J., Scott, D. J., Terrill, N. J., King, S. M., Butler, P. D. & Curtis, J. E. (2016). J. Appl. Cryst. 49, 1861–1875.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationSavelyev, A. & Brookes, E. (2019). Future Generation Comput. Syst. 94, 929–936.  Google Scholar
First citationSedlak, S. M., Bruetzel, L. K. & Lipfert, J. (2017). J. Appl. Cryst. 50, 621–630.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationSkar-Gislinge, N. & Arleth, L. (2011). Phys. Chem. Chem. Phys. 13, 3161–3170.  Web of Science CAS PubMed Google Scholar
First citationTowns, J., Cockerill, T., Dahan, M., Foster, I., Gaither, K., Grimshaw, A., Hazlewood, V., Lathrop, S., Lifka, D., Peterson, G. D., Roskies, R., Scott, J. & Wilkins-Diehr, N. (2014). Comput. Sci. Eng. 16, 62–74.  Google Scholar
First citationWillendrup, P. K. & Lefmann, K. (2021). J. Neutron Res. 23, 7–27.  Google Scholar

This is an open-access article distributed under the terms of the Creative Commons Attribution (CC-BY) Licence, which permits unrestricted use, distribution, and reproduction in any medium, provided the original authors and source are cited.

Journal logoJOURNAL OF
APPLIED
CRYSTALLOGRAPHY
ISSN: 1600-5767
Follow J. Appl. Cryst.
Sign up for e-alerts
Follow J. Appl. Cryst. on Twitter
Follow us on facebook
Sign up for RSS feeds