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

Merged
merged 1 commit into from
Jan 31, 2025

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.

@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.

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.

LGTM! :shipit:

plt.axhline(summed_background, color='k', linestyle='--', label = "background")
plt.xlabel("time (s)")
plt.ylabel("Photon counts")
plt.title("Photon counts along binding event")
Copy link
Member

Choose a reason for hiding this comment

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

Extremely minor, but you have labels specified in the plt.plot() calls, but don't actually show them by invoking plt.legend().

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch! I updated it.

@aafkevandenberg aafkevandenberg enabled auto-merge (rebase) January 31, 2025 15:44
@aafkevandenberg aafkevandenberg merged commit bb128c0 into main Jan 31, 2025
8 checks passed
@aafkevandenberg aafkevandenberg deleted the photon-counts branch January 31, 2025 15:49
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