I made the following table

in LaTex with the following code:
\documentclass{article}
\begin{document}
\begin{table}[ph]
\protect\caption{Genotype-by-Environment Means}
\centering{}%
\begin{tabular}{l|cccccc|c}
\hline
& \multicolumn{6}{c|}{Environment} & \tabularnewline
\cline{2-7}
Genotype & $1$ & $2$ & $\ldots$ & $j$ & $\ldots$ & $e$ & Mean\tabularnewline
\hline
$1$ & $\overline{Y}_{11.}$ & $\overline{Y}_{12.}$ & $\ldots$ & $\overline{Y}_{1j.}$ & $\ldots$ & $\overline{Y}_{1e.}$ & $\overline{Y}_{1..}$\tabularnewline
$2$ & $\overline{Y}_{21.}$ & $\overline{Y}_{22.}$ & $\ldots$ & $\overline{Y}_{2j.}$ & $\ldots$ & $\overline{Y}_{2e.}$ & $\overline{Y}_{2..}$\tabularnewline
$\vdots$ & $\vdots$ & $\vdots$ & $\ddots$ & $\vdots$ & $\ddots$ & $\vdots$ & $\vdots$\tabularnewline
$i$ & $\overline{Y}_{i1.}$ & $\overline{Y}_{i2.}$ & $\ldots$ & $\overline{Y}_{ij.}$ & $\ldots$ & $\overline{Y}_{ie.}$ & $\overline{Y}_{i..}$\tabularnewline
$\vdots$ & $\vdots$ & $\vdots$ & $\ddots$ & $\vdots$ & $\ddots$ & $\vdots$ & $\vdots$\tabularnewline
$g$ & $\overline{Y}_{g1.}$ & $\overline{Y}_{g2.}$ & $\ldots$ & $\overline{Y}_{gj.}$ & $\ldots$ & $\overline{Y}_{ge.}$ & $\overline{Y}_{g..}$\tabularnewline
\hline
Mean & $\overline{Y}_{.1.}$ & $\overline{Y}_{.2.}$ & $\ldots$ & $\overline{Y}_{.j.}$ & $\ldots$ & $\overline{Y}_{.e.}$ & $\overline{Y}_{...}$\tabularnewline
\hline
\end{tabular}
\end{table}
\end{document}
Now I want to make some drawing on this table as below:

I used tikz for this and the code is:
\documentclass{article} % article standalone
\usepackage{tikz}
\usetikzlibrary{matrix}
\tikzset{
table/.style={
matrix of math nodes,
row sep=-\pgflinewidth,
column sep=-\pgflinewidth,
nodes={rectangle,draw=black,text width=3.3em,align=center},
text depth=0.25ex,
text height=2ex,
nodes in empty cells
}
}
\begin{document}
\begin{table}
\begin{tikzpicture}
\matrix (m) [table] {
%& K=3 & K=4 & K=5 & K=6 & K=7 & K=8 & K=9 & K=10 & K=11 & K=12\\
\hline
1 & \overline{Y}_{11.} & \overline{Y}_{12.} & \ldots & \overline{Y}_{1j.} & \ldots & \overline{Y}_{1e.} & \overline{Y}_{1..} \\
2 & \overline{Y}_{21.} & \overline{Y}_{22.} & \ldots & \overline{Y}_{2j.} & \ldots & \overline{Y}_{2e.} & \overline{Y}_{2..} \\
\vdots & \vdots & \vdots & \ddots & \vdots & \ddots & \vdots & \vdots \\
i & \overline{Y}_{i1.} & \overline{Y}_{i2.} & \ldots & \overline{Y}_{ij.} & \ldots & \overline{Y}_{ie.} & \overline{Y}_{i..} \\
\vdots & \vdots & \vdots & \ddots & \vdots & \ddots & \vdots & \vdots \\
g & \overline{Y}_{g1.} & \overline{Y}_{g2.} & \ldots & \overline{Y}_{gj.} & \ldots & \overline{Y}_{ge.} & \overline{Y}_{g..} \\
\textrm{Mean} & \overline{Y}_{.1.} & \overline{Y}_{.2.} & \ldots & \overline{Y}_{.j.} & \ldots & \overline{Y}_{.e.} & \overline{Y}_{...} \\
};
\begin{scope}[shorten >= 10pt,shorten <= 10pt]
\draw[red, thick] (m-4-2.west) -- (m-4-8.east);
\end{scope}
\end{tikzpicture}
\end{table}
\end{document}

Any help will be highly appreciated. Thanks
Edited
I want to use this table in beamer. On first frame the table without marker (red in hand made figure) and one second frame the table with marker (red in hand made figure). So what is the best approach. Thanks


