1
$\begingroup$

As done in this paper here:

I would like to linearly scale a distribution such that it has the same 5th and 95th percentile (0.05 and 0.95 quantile) as another distribution.

That is, given two genes on two different platforms, how do I scale them to have the same 5th and 95th % percentile.

$\endgroup$
0

1 Answer 1

0
$\begingroup$

Let's say the 5th percentile of $X$ is $l_x$ and the 95th percentile is $u_x$, and similarly for $Y$.

You now want to construct a linear transformation $Z=aX+b$ such that $l_z = l_y$ and $u_z=u_y$.

Note that $\frac{X-l_x}{u_x-l_x}$ has the required percentiles at 0 and 1.

Hence $Z=l_y+(u_y-l_y)\frac{X-l_x}{u_x-l_x}$ should match those percentiles with $Y$.

Here's an example in R:

 x=rnorm(100)
 y=rgamma(100,3,.2)

 quantile(x,c(.05,.95))
       5%       95% 
-1.685679  1.517378 

 quantile(y,c(.05,.95))
       5%       95% 
 4.724867 29.434846 

 lx=quantile(x,.05)
 ux=quantile(x,.95)
 ly=quantile(y,.05)
 uy=quantile(y,.95)
 z=ly+(uy-ly)*(x-lx)/(ux-lx)

 quantile(z,c(.05,.95))
       5%       95% 
 4.724867 29.434846 
$\endgroup$
8
  • $\begingroup$ Correlation is not affected at all by linear rescaling. If that code snippet is actually what they do, it would be wrong. $\endgroup$
    – Glen_b
    Nov 12, 2015 at 2:16
  • $\begingroup$ Looking at the code (unless I am looking at the wrong place), I don't think your code exactly represents what they did. $\endgroup$
    – Glen_b
    Nov 12, 2015 at 6:48
  • $\begingroup$ Is it possible you update your answer to cover what they implemented. This is my end goal. $\endgroup$
    – David shaw
    Nov 12, 2015 at 11:04
  • $\begingroup$ @David As far as I can see, what they did is what I say above. $\endgroup$
    – Glen_b
    Nov 12, 2015 at 13:49
  • $\begingroup$ I have 100 samples measured on two platforms, which is what I have implemented this linear transformation on. I have an additional 900 samples on one array, is it possible to also transform this data even though it doesn't have matched samples? How would I do this? The paper mentions the following: 'We performed this scaling strategy using only samples from brain 2, and reserved brain 1 as an independent test set.' $\endgroup$
    – David shaw
    Nov 12, 2015 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.