<p>If you read your matrix into R and saved it as <code>m</code>:</p>

<pre class="lang-r prettyprint-override"><code>diffMatrix = m[,2:9] - m[,1:8]  # The change per-timepoint
l2n = apply(diffMatrix, 2, function(x) sqrt(sum(x^2)))  # The L2-norm
</code></pre>

<p>R also has a <code>norm()</code> function, which can directly produce the L2-norm, but it turns out that <a href="https://stackoverflow.com/questions/10933945/how-to-calculate-the-euclidean-norm-of-a-vector-in-r">this is slower</a> than the simple method shown here. If you click through to the other question you can find somewhat faster implementations of this, but anything will suffice for small datasets like yours.</p>

CC BY-SA 4.0
2018-07-02T15:25:58.080Z
Sorry, How can I normalise these 8 points to zero time point?     12n= Named num [1:8] 313698 168553 360237 487963
Zizogolu
CC BY-SA 4.0
2018-07-02T18:51:59.620Z
That depends entirely on how you want the normalization done.
Devon Ryan
CC BY-SA 4.0
2018-07-02T19:04:43.617Z
Sorry I mean how I can normalize these 9 differences you helped me to calulate  to expression at 0 h, which corresponds to cells growing in ground state conditions?? Because they are very big and I can not plot them
Zizogolu
CC BY-SA 4.0
2018-07-02T19:07:00.057Z
You wouldn't, it doesn't make sense to normalize a difference between two time points to a third one. You could normalize everything before subtraction though.
Devon Ryan
CC BY-SA 4.0
2018-07-02T19:25:01.963Z
Right, actually the goal was showing global gene expression dynamics as measured by bulk RNA-seq. I was going to plot a data point at a certain time point represents the 2-norm of the difference between the gene expression vector at that time point and the previous time point. However these differences are too big to be plotted. Thank you
Zizogolu
CC BY-SA 4.0
2018-07-02T20:21:39.113Z
Try something like plotting log2(TPM) in violin or joy plots. If there are changes in the distribution of expressed genes over time then that should make it apparent.
Devon Ryan
CC BY-SA 4.0
2018-07-01T17:36:21.970Z
2018-07-01T17:36:21.970Z
Devon Ryan
<p>I have gene expression RNA-seq data of 9 time points (0 hour, 2 hour, ..., 16 hour). I need a plot on which x axis is time point and each data point at a certain time point represents the L2 norm (Euclidean norm) of the difference between the gene expression vector at that time point and the previous time point.</p>

<p>This is the link of my expression data</p>

<p><a href="https://drive.google.com/file/d/1crJSqVdGujy1tFyeoV6E7e-xO9SXteJZ/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1crJSqVdGujy1tFyeoV6E7e-xO9SXteJZ/view?usp=sharing</a></p>

<r>
Calculating L2 norm (Euclidean norm) to set of genes in time series
# Calculating L2 norm (Euclidean norm) to set of genes in time series

(Asked by: username_0 on 2018-06-29)

I have gene expression RNA-seq data of 9 time points (0 hour, 2 hour, ..., 16 hour). I need a plot on which x axis is time point and each data point at a certain time point represents the L2 norm (Euclidean norm) of the difference between the gene expression vector at that time point and the previous time point.

This is the link of my expression data

<https://drive.google.com/file/d/1crJSqVdGujy1tFyeoV6E7e-xO9SXteJZ/view?usp=sharing>

**Tags:** r

---

## 1 answers

### Answer by username_1 on 2018-07-01. Score: 1 | Accepted answer

If you read your matrix into R and saved it as m:
diffMatrix = m[,2:9] - m[,1:8]  # The change per-timepoint
l2n = apply(diffMatrix, 2, function(x) sqrt(sum(x^2)))  # The L2-norm

R also has a norm() function, which can directly produce the L2-norm, but it turns out that this is slower than the simple method shown here. If you click through to the other question you can find somewhat faster implementations of this, but anything will suffice for small datasets like yours.

> **Comments:**
> **username_0**: Sorry, How can I normalise these 8 points to zero time point?     12n= Named num [1:8] 313698 168553 360237 487963  
> **username_1**: That depends entirely on how you want the normalization done.  
> **username_0**: Sorry I mean how I can normalize these 9 differences you helped me to calulate  to expression at 0 h, which corresponds to cells growing in ground state conditions?? Because they are very big and I can not plot them  
> **username_1**: You wouldn't, it doesn't make sense to normalize a difference between two time points to a third one. You could normalize everything before subtraction though.  
> **username_0**: Right, actually the goal was showing global gene expression dynamics as measured by bulk RNA-seq. I was going to plot a data point at a certain time point represents the 2-norm of the difference between the gene expression vector at that time point and the previous time point. However these differences are too big to be plotted. Thank you  
> **username_1**: Try something like plotting log2(TPM) in violin or joy plots. If there are changes in the distribution of expressed genes over time then that should make it apparent.  

---

