[Tutor] Translating R Code to Python-- reading in csv files, writing out to csv files
Benjamin G
benjaming286 at gmail.com
Sat May 19 19:46:42 CEST 2012
I'm trying to improve my python by translating R code that I wrote into
Python. I've been reading about the python csv module and realized it was
best to get some expert input to clarify some confusion on my part. As
background, GSEXXXXX_full_pdata.csv has different patient information (such
as unique patient ID's, whether the tissue used was tumor or normal, and
other things. I'll just use the first two characteristics for now).
Template.csv is a template we built that allows us to take different
datasets and standardize them for meta-analysis. So for example,
"curated$alt_sample_name" refers to the unique patient ID, and
"curated$sample_type" refers to the type of tissue used. Here is sample
code in R.
uncurated <- read.csv("../uncurated/GSEXXXXX_full_pdata.csv",as.is
=TRUE,row.names=1)
##initial creation of curated dataframe
curated <-
initialCuratedDF(rownames(uncurated),template.filename="template.csv")
##--------------------
##start the mappings
##--------------------
##title -> alt_sample_name
tmp <- uncurated$title
curated$alt_sample_name <- tmp
##sample_type are all tumor
curated$sample_type <- "tumor"
_________________________________________________________________
In Python, I have figured out how to assign "uncurated" and "curated" to
the correct paths. *My trouble arose when trying to execute the following
R code:*
##title -> alt_sample_name
tmp <- uncurated$title
curated$alt_sample_name <- tmp
*All I am trying to do is take in a specific column in "uncurated" and
write that whole column as output to "curated." It should be a pretty basic
command, I'm just not clear on how to execute it.*
Thanks,
benjamin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120519/cbfda9e7/attachment.html>
More information about the Tutor
mailing list