\HeaderA{translateSampleNames}{Translate sample names using translation file}{translateSampleNames}
\aliasA{translateSampleNames,ExpressionSet-method}{translateSampleNames}{translateSampleNames,ExpressionSet.Rdash.method}
\keyword{documentation}{translateSampleNames}
\keyword{utilities}{translateSampleNames}
\begin{Description}\relax
Function that will change sample names in an ExpressionSet using a translation file.
\end{Description}
\begin{Usage}
\begin{verbatim}
    translateSampleNames(object, translationFile, from, to)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{object}] An ExpressionSet
\item[\code{translationFile}] Character string with the path to a tab-separated text file with translations of names. Alternatively a data frame containing translation information.
\item[\code{from}] Character string with the translationFile column name containing the values to translate from.
\item[\code{to}] Character string with the translationFile column name containing the values to translate to.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Function that can translate the sampleNames of an ExpressionSet when given translation information.
The translationFile argument gives the translation between sampleNames as they are and the sampleNames as they should be. 
It can either be a character string with the path to a tab-separated text-file with headers or a directly a data frame with
the necessary information. The variables 'from' and 'to' specify the column names that contains the translation information.
They must be present in the translationFile and the entries in 'from' must be present in the sampleNames of the 
current ExpressionSet. Extra entries in the translationFile are omitted but samples in the ExpressionSet without 
samples in the translationFile will raise an error.

This package is particularly useful after running cel-files through the Affymetrix Power Tools 
(with \LinkA{getLocalProbeIntensities}{getLocalProbeIntensities} for example), since this program has a tendency to change any odd 
character in the filename to something else.
\end{Details}
\begin{Value}
The same ExpressionSet given as argument, but with sampleNames changed as specified in translationFile
\end{Value}
\begin{Author}\relax
Lasse Folkersen
\end{Author}
\begin{Examples}
\begin{ExampleCode}

        data(exampleProbeLevelSet)
        
        fromThese<-sampleNames(exampleProbeLevelSet)
        
        toThese<-sub(".cel","", sampleNames(exampleProbeLevelSet))
        toThese<-sub("X","", toThese)
        

        translationFile<-cbind(fromThese, toThese)
        translationFile<-as.data.frame(translationFile)
        
        translateSampleNames(exampleProbeLevelSet, translationFile, from="fromThese", to="toThese")
                                
        
\end{ExampleCode}
\end{Examples}

