0

thanks to the truely amazing community my project group is one step closer to mimic realistic calcium baseline noise.

I simulated a typical calcium movement in a mathematical model: enter image description here

Thanks to the community I could add random noise to the unrealistic baseline:

enter image description here

However, the noise dynamic is actually too fast. Is there a way to slow down the noise and create broader noise peaks instead of these spikes. I add an actual measurement to show you what I mean:

enter image description here

If this question is too specific, I apologize and will delete the post.

Best wishes and many thanks!

Arne
  • 337
  • 1
  • 6
  • 17

2 Answers2

2

Please make your question and examples reproducible so that others can help. That being said, it looks like the baseline is a just a random normal -- probably created with something like x <- rnorm(500). One way to make this less jumpy is calculate a moving average. You could use a package like TTR or zoo to do this, or you can create your own function. For example:

x <- rnorm(500)
plot(x, type = "l")

enter image description here

ma <- function(x, n = 5){ filter(x, rep(1/n, n), sides = 2) }
plot(ma(x), type = "l")

enter image description here

plot(ma(x, 10), type = "l")

enter image description here

Community
  • 1
  • 1
JasonAizkalns
  • 20,243
  • 8
  • 57
  • 116
  • Thank you, Jason - the result looks good; however, for my purpose I would have to choose a quite high n-value (ca. 1500) for an x of size 159,957. The higher I go with n, the larger there is a NA-area in the data. First I thought n should simply be a multiple of x but still there is quite a stretch of unidentified Y-values when plotting the data. Is there a way to overcome this? – Arne Oct 27 '15 at 09:39
  • alright simply clipped of the NA-part - thanks to all :) – Arne Oct 27 '15 at 09:55
1

I see your point now. I have two suggestions for this case, maybe they will be of help :

Try to add noise to only a subset of your base line ( following is a 10%)

baseline.index = which(App[,2] == min(App[,2]))
baseline.index.subset = sample(x = baseline.index, size = 0.1 * length ( baseline.index) , replace = F)
noise = rnorm( length (baseline.index.subset))
App[ baseline.index.subset,2] = App[ baseline.index.subset,2] + noise

And try to play a bit with the mean and standard deviation of the noise. ie:

noise = rnorm( length (baseline.index.subset), mean = 0, sd = 0.1)

Let us know if this helps