Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kymograph tutorial: add section on photon counts #717

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

aafkevandenberg
Copy link
Collaborator

I frequently get questions about this workflow, so I added an example.
I decided to add the example in the 'Tutorial', but it would also fit under 'Examples'
On the one hand, there is no new syntax introduced, which makes it fit under 'Examples'.
On the other hand, the example is just very short and does not represent a full workflow, which makes it fit in the 'Tutorial'. Let me know what you think.

Copy link
Member

@JoepVanlier JoepVanlier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I frequently get questions about this workflow, so I added an example.

Nice! What questions do you typically get? I'm wondering whether people ask about this mostly for plotting or analyzing the counts further.

The reason I'm asking is because subtracting the offset changes the distribution. Especially when counts are low, it can make downstream analysis messier than if one were to keep the counts as is, but include a constant background count in the model used to analyze the data.

docs/tutorial/kymographs.rst Outdated Show resolved Hide resolved
docs/tutorial/kymographs.rst Outdated Show resolved Hide resolved
docs/tutorial/kymographs.rst Outdated Show resolved Hide resolved
docs/tutorial/kymographs.rst Outdated Show resolved Hide resolved
docs/tutorial/kymographs.rst Outdated Show resolved Hide resolved
docs/tutorial/kymographs.rst Outdated Show resolved Hide resolved
docs/tutorial/kymographs.rst Outdated Show resolved Hide resolved
@aafkevandenberg
Copy link
Collaborator Author

aafkevandenberg commented Jan 7, 2025

I frequently get questions about this workflow, so I added an example.

Nice! What questions do you typically get? I'm wondering whether people ask about this mostly for plotting or analyzing the counts further.

The reason I'm asking is because subtracting the offset changes the distribution. Especially when counts are low, it can make downstream analysis messier than if one were to keep the counts as is, but include a constant background count in the model used to analyze the data.

Hi Joep,

I often get request such as 'I would like to plot the photon intensity of a specific region and subtract background'. A possible application could be

  • determine the stoichiometry (ie look at step sizes in the signal intensity)
  • Sum the intensity over a certain region of DNA and observe how the summed intensity decreases over time, due to bleaching or unbinding. For example, because users are interested in facilitated dissociation, or in the exchange rate of molecules in a biocondensate.

Often users would like to translate the signal intensity to the number of dyes bound to DNA, and therefore subtract the background.
Could you give a specific example of when it is better to keep the background as a separate parameter?
Keeping the background separate is anyway a good idea. I have rewritten the instructions, such that photon_counts and background remain separate parameters.

@JoepVanlier
Copy link
Member

I often get request such as 'I would like to plot the photon intensity of a specific region and subtract background'. A possible application could be

For this what you have in this PR is fine.

determine the stoichiometry (ie look at step sizes in the signal intensity)

Given that counts are high and the steps are very clear, this should also be fine.

Sum the intensity over a certain region of DNA and observe how the summed intensity decreases over time, due to bleaching or unbinding. For example, because users are interested in facilitated dissociation, or in the exchange rate of molecules in a biocondensate.

Often users would like to translate the signal intensity to the number of dyes bound to DNA, and therefore subtract the background. Could you give a specific example of when it is better to keep the background as a separate parameter?

It depends. When Poisson-noise dominates, the distributions are very tailed and you may find that subtracting offsets doesn't allow you to use a Poisson model for fitting anymore. Reason being that the count model depends on the total intensity (and that includes the background). In that case, it might be better to include the background (you could still pre-estimate it on a different section of data and make it a fixed parameter) in the model and fit the raw data as is.

Keeping the background separate is anyway a good idea. I have rewritten the instructions, such that photon_counts and background remain separate parameters.

👍

Copy link
Member

@JoepVanlier JoepVanlier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a few small errors that prevent the notebook from being rendered/run correctly.

docs/tutorial/kymographs.rst Outdated Show resolved Hide resolved
docs/tutorial/kymographs.rst Outdated Show resolved Hide resolved
time = np.arange(len(photon_counts)) * kymo.line_time_seconds

plt.figure()
plt.plot(time, summed_photon_counts - summed_background)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel super strongly about this, but another option would be to indicate the background level and leave the data as-is.

Suggested change
plt.plot(time, summed_photon_counts - summed_background)
plt.plot(time, summed_photon_counts)
plt.axhline(summed_background, color='k', linestyle='--')

Then you could still call them counts. Anyways, your call on that one.

It would be nice if we had some data with clear bleaching steps and just make a fully worked example for stoichiometry analysis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants