Injectivity of associate map of affine scheme homomorphism Let $R$ be a ring and the corresponding $(\text{Spec } R, \mathcal{O}_{\text{Spec } R})$ be the affine scheme where $\mathcal{O}_{\text{Spec } R}$ is the structured sheaf of rings. By definition, the structure sheaf $\mathcal{O}_{\text{Spec} R}$ provides restriction (ring) homomorphism
$$\rho_{V,U} : \mathcal{O}_{\text{Spec } R}(V) \rightarrow \mathcal{O}_{\text{Spec } R}(U)$$
for every open subsets $U \subseteq V \subseteq \text{Spec} R$.
Let $U \subseteq \text{Spec } R$ be such an open subset. We have in particular restriction from the global section $\rho = \rho_{\text{Spec } R,U}$ (namely where $V = \text{Spec} R$):
$$\rho : R \rightarrow \mathcal{O}_{\text{Spec } R}(U)$$
(Recall that the global section $\mathcal{O}_{\text{Spec } R}(\text{Spec } R) = R$.)
Now since $\rho$ is a ring homomorphism, one has the associated map
$$\rho^* : \text{Spec } \mathcal{O}_{\text{Spec } R}(U) \rightarrow \text{Spec } R.$$
It is suggestive and not difficult to see that the image $\rho^*$ is exactly $U$. What about injectivity?
EDIT: Here is my argument that image $\rho^*$ is exactly $U$. It might contain some mistake somewhere. For simplicity, let me write $X = \text{Spec }R$ and drop $\text{Spec } R$ in $\mathcal{O}_{\text{Spec } R}$ for there should be no confusion. Recall general sheafification:
$$\mathcal{O}(U) = \left\{ f : U \rightarrow \bigsqcup_{\mathfrak{p} \in U}\mathcal{O}_\mathfrak{p} \text{ satisfying } (*)\right\}$$
where (*) says that
(i) for any $\mathfrak{p} \in U$, $f(\mathfrak{p}) \in \mathcal{O}_\mathfrak{p}$; and
(ii) for any $\mathfrak{p} \in U$, there exists basic open neighborhood of $\mathfrak{p}$, say $X_r = \{\mathfrak{p} \in \text{Spec }R : r \not\in \mathfrak{p}\}$ for some $r \in R$ such that $X_r \subseteq U$ and some  $s \in R_r$ (the localization of $R$ at the multiplicative set $\{1, r, r^2, ...\}$) such that $f(\mathfrak{q}) = \text{image of } s \text{ in } \mathcal{O}_{\mathfrak{q}}$ for any $\mathfrak{q} \in X_r$. Also recall that the stalk $\mathcal{O}_\mathfrak{p}$ can be identified with local ring $R_\mathfrak{p}$.
$\mathcal{O}(U)$ is a ring under point-wise addition and multiplication. The sheaf restriction is given $\mathcal{O}(U) \rightarrow \mathcal{O}(V)$ by restriction of functions. The ring of global section $\mathcal{O}(X) \cong R$ where one identifies $r \in R$ with the function $f : \mathfrak{p} \mapsto r/1 \in R_\mathfrak{p}$. The restriction map $\rho : R \rightarrow \mathcal{O}(U)$
is therefore given by
$$r \mapsto (\mathfrak{q} \mapsto r/1 \in R_\mathfrak{q})$$
Now given arbitrary $\mathfrak{p} \in U$, define
$$\mathfrak{P} = \left\{ f \in \mathcal{O}(U) \;|\; f(\mathfrak{p}) \in \mathfrak{p} R_\mathfrak{p} \right\}$$
which is evidently an ideal of $\mathcal{O}(U)$. It is also prime ideal since if $f_1, f_2 \in \mathcal{O}(U)$ be such that $f_1 f_2 \in \mathcal{O}(U)$ i.e. $(f_1 f_2)(\mathfrak{p}) \in \mathfrak{p} R_\mathfrak{p}$ then $f_1(\mathfrak{p}) f_2(\mathfrak{p}) \in \mathfrak{p} R_\mathfrak{p}$ by definition of multiplication in $\mathcal{O}(U)$. But then either $f_1(\mathfrak{p}) \in \mathfrak{p} R_\mathfrak{p}$ or $f_2(\mathfrak{p}) \in \mathfrak{p} R_\mathfrak{p}$ because $\mathfrak{p} R_\mathfrak{p}$ is maximal (hence prime) ideal of $R_\mathfrak{p}$. So either $f_1 \in \mathfrak{P}$ or $f_2 \in \mathfrak{P}$.
We check that $\rho^*(\mathfrak{P}) = \mathfrak{p}$. Recall that $\rho^*(\mathfrak{P}) = \rho^{-1}(\mathfrak{P}) = \{r \in R \;|\; \rho(r) \in \mathfrak{P}\}$. Now $\rho(r)$ is the function sending $\mathfrak{q} \in U$ to the element $r/1$ in $R_\mathfrak{q}$. So $\rho(r) \in \mathfrak{P}$ only when $r/1 \in \mathfrak{p} R_\mathfrak{p}$. By basic commutative algebra fact, $\mathfrak{p} R_\mathfrak{p} \cap R = \mathfrak{p}$ so $r \in \mathfrak{p}$ if $r \in \rho^*(\mathfrak{P})$. This proves $\rho^*(\mathfrak{P}) \subseteq \mathfrak{p}$. The reverse inclusion is evident: for any $r \in \mathfrak{p}$, the function $\mathfrak{q} \mapsto r/1$ is in $\mathfrak{P}$.
So we proved that the image of $\rho^*$ contains $U$. It is not hard to see that the image is contained in $U$.
Remark: Given the image of $\rho^*$ being exactly $U$, I feel that $\rho^*$ is in fact a homeomorphism. We can take open subsets of $U$ and the argument gives a corresponding open subset in $\mathcal{O}(U)$.
 A: $U$ is contained in the image of $\rho^\ast$, which we can see by covering $U$ with principal opens $D(f)\subset U \subset \operatorname{Spec}R$, giving us restriction maps $R\to \Gamma(U) \to R_f$ that allow us to pull back primes of $R_f$.
But $\rho^\ast$ need not have image $U$.  Let $R=k[X,Y]$, $U=\operatorname{Spec}R \setminus \{(X,Y)\}$, so that $U$ is the affine plane minus a point.  It is a standard result that the map $R\to\Gamma(U)$ is an isomorphism; every regular function on $U$ extends to all of $\operatorname{Spec} k[X,Y]$.
We can use a similar example to see that $\rho^\ast$ need not be injective: Let $I=(X,Y)(Z,W)$, $R = k[X,Y,Z,W]/I$, so that $\operatorname{Spec} R$ is two affine planes meeting at a point.  If $U$ is $\operatorname{Spec} R$ minus the origin, then $U$ is isomorphic to the disjoint union of two punctured planes, so $\Gamma(U) \cong k[X,Y]\times k[Z,W]$.  We can see that the two origins of $\operatorname{Spec} \Gamma(U)$ are both mapped to the origin of $\operatorname{Spec R}$.
I think it is an interesting question whether $\operatorname{Spec} \Gamma(U)\to\operatorname{Spec} R$ is injective on $U$, i.e. whether $U\times_X \operatorname{Spec} \Gamma(U) \to U$ is injective.  I suspect that this is false in general, because $\Gamma(U)$ can in principle have a very complicated structure (it is only an inverse limit of localizations of $R$).  But there may be nice situations (like varieties?) in which it is true.
