I am using Galaxy for the NGS analysis. When I use tools like featureCounts, DESeq, etc., it gives output file in .tabular format. I need to see this data in a well-organized table in Microsoft Excel (xlsx) format. Could anyone help, please?
Hello Glory Basumata ,
first of all: You don't realy want to do this. It is very likely, that at a later points you will convert it back to something, that a too, which you like to use for further analysis, needs and then the nightmare begins ...
If you don't take care of my warning than you simply can open those files in excel. It will ask you how to convert and you have to select that those file are tab delimited. In the next step you can choose what is the decimal seperator.
But you have to be aware that excel also might try to convert some values to something it believe it could be. So e.g. a gene called
So again: DON'T DO THIS!
here is an python script which takes as first argument TSV and second argument creates xlsx file.
import csv import sys reload(sys) sys.setdefaultencoding('utf8') from xlsxwriter.workbook import Workbook # Add some command-line logic to read the file names. tsv_file = sys.argv xlsx_file = sys.argv # Create an XlsxWriter workbook object and add a worksheet. workbook = Workbook(xlsx_file) worksheet = workbook.add_worksheet() # Create a TSV file reader. tsv_reader = csv.reader(open(tsv_file, 'rb'), delimiter='\t') # Read the row data from the TSV file and write it to the XLSX file. for row, data in enumerate(tsv_reader): worksheet.write_row(row, 0, data) # Close the XLSX file. workbook.close()
You can save this code to file as conversion.py and make executable:
chmod +x conversion.py
Then run it as:
./conversion.py input.tsv output.xlsx