In [1]:
import pandas as pd
import numpy as np
import pandas as pd
import numpy as np
from IPython.display import HTML
import latools as la
from comparison_tools import helpers, stats, plots
%matplotlib inline
In [2]:
HTML(filename="./Parameter_Tables/cultured_forams.html")
Out[2]:
NB: Per-element dwell times not recorded.
In [3]:
dat = la.analyse('raw_data/cultured_foram/', srm_identifier='STD')
In [4]:
sample = 'C3_A' # modify to change which is plotted throughout.
_ = dat.data[sample].tplot()
In [5]:
dat.despike()
In [6]:
_ = dat.data[sample].tplot()
In [7]:
dat.autorange(on_mult=[2, 1], off_mult=[1, 3])
In [8]:
_ = dat.data[sample].tplot(ranges=True)
In [9]:
dat.bkg_calc_weightedmean(weight_fwhm=800, n_min=60, bkg_filter=True)
In [10]:
dat.bkg_plot()
Out[10]:
Sr backgrounds a little odd - check autorange isn't erroneously including 'signal' in the background regions:
In [11]:
_ = dat.data['E6-F1_A'].tplot(ranges=True)
Looks fine - proceed with background correction
In [12]:
dat.bkg_subtract()
In [13]:
_ = dat.data[sample].tplot(ranges=True)
In [14]:
dat.ratio()
In [15]:
_ = dat.data[sample].tplot(ranges=True)
In [16]:
dat.calibrate(srms_used=['NIST610', 'NIST612', 'NIST614'])
In [17]:
_ = dat.calibration_plot()
The Sr87 calibration has a non-zero intercept, suggesting a possible isobaric interference. As we are not seeking to quantitatively determine Sr87 in these samples (it is used as a marker only), we will continue using a calibration line with a non-zero intercept.
In [18]:
dat.calibrate('Sr87', srms_used=['NIST610', 'NIST612', 'NIST614'], zero_intercept=False)
In [49]:
_ = dat.calibration_plot()
In [20]:
dat.filter_clear()
These data contain analyses of O. universa and N. dutertreii. These need to be treated separately during filtering, so we divide the data into two subsets.
In [21]:
# subsets
dat.make_subset([s for s in dat.samples if (s[0] == 'B') | (s[0] == 'C') | (s[0] == 'E')], 'dut')
dat.make_subset([s for s in dat.samples if (s[0] != 'B') & (s[0] != 'C') & (s[0] != 'E') & (s[0] != 'S')], 'orb')
Out[21]:
In [22]:
_ = dat.data['LN1_A'].tplot(filt=False)
In [23]:
_ = dat.crossplot(subset='orb')
The data look fairly clean. High Al27 values are indicative of the carbon tape used to mount the specimens, and should be removed.
The two clusters in Sr87/Sr88 indicate material grown in or out of culture conditions, which were elevated in Sr86.
In [24]:
dat.filter_clear(subset='orb')
dat.filter_threshold('Al27', 0.2e-3, subset='orb')
dat.filter_on('below', subset='orb', show_status=True)
In [25]:
_ = dat.data['LN1_A'].tplot(filt=True)
In [26]:
_ = dat.data['C4-F_A'].tplot(filt=False)
In [27]:
_ = dat.crossplot(subset='dut')
Similarly, the dutertrei data look relatively clean, with two distinct data populations representing culture grown and wild-grown calcite.
Apply a few threshold filters to remove some of the high outliers.
In [28]:
dat.filter_clear(subset='dut')
dat.filter_threshold('Al27', 0.1e-3, subset='dut')
dat.filter_threshold('Ba138', 6e-6, subset='dut')
dat.filter_threshold('Mg24', 15e-3, subset='dut')
dat.filter_on('Ba138_thresh_below', subset='dut')
dat.filter_on('below', subset='dut', show_status=True)
In [29]:
_ = dat.data['C4-F_A'].tplot(filt=True)
In [30]:
dat.filter_exclude_downhole(5, subset='dut')
dat.filter_off(subset='dut')
dat.filter_on('downhole', subset='dut')
In [31]:
_ = dat.data['C4-F_A'].tplot(filt=True)
In [32]:
dat.sample_stats(stats=['mean', 'std', 'stderr'])
In [33]:
ld = dat.getstats().loc['mean'] * 1e3
In [34]:
dat.minimal_export(path='raw_data/cultured_foram_export/minimal_export.zip')
In [35]:
rd = helpers.load_reference_data('culture_reference')
td = helpers.load_reference_data('culture_test')
# ld = helpers.read_latools_data('Jenn_Data_export/clean_Alfilt.csv')
# combine all data
df = rd.join(td, lsuffix='_r', rsuffix='_t')
df = df.join(ld)
In [36]:
# number of unique samples
np.unique(rd.index.levels[0]).size
Out[36]:
In [37]:
_ = stats.pairwise_reproducibility(ld, plot=True)
In [38]:
_ = stats.pairwise_reproducibility(td, plot=True)
In [39]:
_, rep_dists, rep_stats, _ = stats.pairwise_reproducibility(rd, plot=True)
In [40]:
rep = pd.DataFrame(rep_stats).T
rep.columns = ['50%', '95%']
rep = rep.loc[['Mg/Ca', 'Sr/Ca', 'Ba/Ca', 'Al/Ca'],:]
In [41]:
rep.to_csv('reproducibility_quants.csv')
In [42]:
# fig, axs = plots.comparison_plots(df, els=['Mg', 'Sr', 'Ba', 'Al'])
In [43]:
# fig, axs = plots.residual_plots(df, rep_stats, els=['Mg', 'Sr', 'Ba', 'Al'])
In [44]:
fig, axs = plots.bland_altman_plots(df, rep_stats=rep_stats, els=['Mg', 'Sr', 'Ba', 'Al'])
fig.savefig('Figures/culture_comparison.pdf')
fig.savefig('Figures/culture_comparison.png', dpi=200)
In [45]:
stat = stats.comparison_stats(df, els=['Mg', 'Sr', 'Ba', 'Al'])
In [46]:
stat.to_csv('Stats/culture_stats.csv')
In [47]:
stat['Test User']
Out[47]:
In [48]:
stat['LAtools']
Out[48]: