-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output file to csv #83
Comments
thank you very much for sharing this :-)
alexis
…On 24.01.19 22:32, Kate Sheridan wrote:
I wrote a quick Python script to convert the output of mPTP to a CSV
file so that I could use the output with ggmap and with other things
where I might want to use the output of mPTP to sort my data in lieu of
other elements of my spreadsheets.
It would be nice if mPTP had a built-in option to export csv versions of
the output alongside the txt file.
Here is the script I wrote, it might not be perfect but if anyone else
needs it it is there:
https://github.com/Lithobius/lazylithobius/tree/master/mPTP2csv.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#83>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA1w-i9GNC59iC8k9beARAYOEXNhxM4sks5vGiZ6gaJpZM4aRwIo>.
--
Alexandros (Alexis) Stamatakis
Research Group Leader, Heidelberg Institute for Theoretical Studies
Full Professor, Dept. of Informatics, Karlsruhe Institute of Technology
www.exelixis-lab.org
|
If any use to anyone, here's also quick R function to read mPTP output as two-column tabular format: # load libs
library("tidyverse")
# load func
read_mptp <- function(file,skiplines) {
mptp.raw <- readr::read_delim(file,skip=skiplines,delim=",",col_names="individual",show_col_types=FALSE)
mptp.tab <- mptp.raw %>%
dplyr::mutate(species=ifelse(grepl(":",individual),individual,NA)) %>%
tidyr::fill(species,.direction="down") %>%
dplyr::filter(!grepl(":",individual)) %>%
dplyr::mutate(species=stringr::str_replace_all(species,":| ","")) %>%
dplyr::relocate(species,.before=individual)
return(mptp.tab)
}
# run func
my.mptp.table <- read_mptp(file="path/to/mptp-output.txt",skiplines=6)
# write out if required
readr::write_csv(my.mptp.table,file="path/to/mptp-output.csv") Note: the skiplines option ignores the first n lines of the mPTP output file containing model parameters. Therefore make sure the skiplines option is correct for your mPTP output. With delimitations starting on line 7, set skiplines to 6 ( |
I wrote a quick Python script to convert the output of mPTP to a CSV file so that I could use the output with ggmap and with other things where I might want to use the output of mPTP to sort my data in lieu of other elements of my spreadsheets.
It would be nice if mPTP had a built-in option to export csv versions of the output alongside the txt file.
Here is the script I wrote, it might not be perfect but if anyone else needs it it is there:
https://github.com/Lithobius/lazylithobius/blob/master/mPTP2csv./mptp2csv.py
The text was updated successfully, but these errors were encountered: